Also consider something like :
<?php
$var = 'a,b,c,';
$var[strrpos($var,',')] = ' ';
print $var; // 'a,b,c '
?>
The idea behind it is similar to this :
<?php
$s = 'abcabc'; // define our string
$s[1] = 'z'; // change second character in $s to 'z'
print $s; // azcabc
$key = strrpos($s,'c'); // 5 (pos of last 'c' in string $s)
print $s[$key]; // c
$s[$key] = 'z'; // change sixth character in $s to z
print $s; // azcabz
?>
Info to know :
strrpos() : Find position of last occurrence of a char in a string
strpos() : Find position of first occurrence of a char in a string
Looks like you found substr() , it helps out for these sorts of things
too :) If anyone has more information on this subject, please post.
Regards,
Philip
On Thu, 29 Mar 2001, Sterling wrote:
> H-
>
> Thanks for the emails and reply.
>
> Someone mentioned substr and after first failing with the attempt I went
> to the PHP site and looked it up.
>
> Here's code that works for what I'm trying to do.
> $test = "tree, bird, nest, ";
> $new = substr($test, 0, strlen($test)-2);
> $new = "$new ";
>
> Appreciate nudges in the right directions.
> -Sterling
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]