|
Posted by ZeldorBlat on 10/09/07 13:23
On Oct 9, 4:14 am, "Ron Barnett" <N...@Spam.Thanks> wrote:
>
> or if they are every other character , regardless of value, try:
>
> $string = '.d.fjdghdjtgkfdhfr';
> $new = '';
> for ($n = 2 to len($string)+1){
> if ($n%2==0) $new .= substr($string,$n-2,1);
>
> }
>
> this will remove all the odd characters,
> testing for $n modulus 2 ==1 will take out the even characters
>
> HTH
>
> Ron
Or, even simpler:
$new = '';
for($i = 1; $i < len($string); $i += 2)
$new .= $string[$i];
Navigation:
[Reply to this message]
|