i'm trying strip every third character (in example period) below best guess , close ive gotten im missing something, minor. method (if working) better regex match, remove?
$arr = 'ha.pp.yb.ir.th.da.y'; $strip = ''; ($i = 1; $i < strlen($arr); $i += 2) { $arr[$i] = $strip; }
one way can is:
<?php $oldstring = 'ha.pp.yb.ir.th.da.y'; $newstring = ""; ($i = 0; $i < strlen($oldstring ); $i++) // loop length of string { if (($i+1) % 3 != 0) // skip every third letter { $newstring .= $oldstring[$i]; // build new string } } // $newstring happybirthday echo $newstring; ?>
alternatively explode() function might work, if letter you're trying remove same one.
Comments
Post a Comment