I found here many responses for my question but I cat't find exactly what I am looking for.
I have to remove every 4th digit from an array, but beginning and the end making a circle, so If I remove 4th digit in next loop It's gonna be another digit (maybe 4th maybe 3rd) It's depend how many digit we have in string
$string = "456345673474562653265326";
$chars = preg_split('//', $string, -1, PREG_SPLIT_NO_EMPTY);
$result = array();
for ($i = 0; $i < $size; $i += 4)
{
$result[] = $chars[$i];
}
You could try doing this with preg_replace:
$string = "12345678901234567890";
$result = preg_replace("/(.{3})\d/", "$1", $string);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With