On Thursday 29 March 2001 22:38, you wrote:
> H-
>
> Thanks to those that emailed.
>
> $query = "tree, bird, nest, ";
> $new = substr($query,0,2);
>
> Doesn't seem to work. It returns "tr".
$new = substr ($query, 0, strlen ($query) - 2);
or
$new = preg_replace ('/,.*?$/', '', $query);
--
Chris
Also consider something like :
The idea behind it is similar to this :
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
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
> That's where I get $query from. It's been returned from a multiple
> select via a web form. I want to format this selected data into a query
> string so I can plug it into a SQL statement.
> Thanks for the input and if any one has any thoughts on the subject
> appreciate the assistance.
If t
H-
Thanks to those that emailed.
$query = "tree, bird, nest, ";
$new = substr($query,0,2);
Doesn't seem to work. It returns "tr".
I think maybe I should also mention that to get this variable I have an
array that is placed through a for loop
// file://loop through array
for($i = 0;$i <$num
5 matches
Mail list logo