php - How to replace first and last 3 characters of a string with asterisk without using any functions? -




i want replace first 3 characters , last 3 characters * sign without using built in functions.

$string = array("johndoee","shawnmarsh","peterparker","johndoee","shawnmarsh","peterparker"); 

can guide me? there way this?

this seems pointless, it's possible using string access , modification character.

foreach ($strings &$string) {     ($i=0; $i < 3; $i++) {         $string[$i] = '*';         $string[-($i+1)] = '*';     } } 

note won't work if string contains multibyte characters, because it's accessing string byte array.

also note requires php 7.1 in order use negative indexes. if don't have php 7.1 don't know of way replace last 3 characters without using functions.





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -