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
Post a Comment