Re: [PHP] Pattern Replacing

2001-03-30 Thread Christian Reiniger
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

Re: [PHP] Pattern Replacing

2001-03-29 Thread Philip Olson
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

Re: [PHP] Pattern Replacing

2001-03-29 Thread Sterling
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

RE: [PHP] Pattern Replacing

2001-03-29 Thread Boget, Chris
> 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

Re: [PHP] Pattern Replacing

2001-03-29 Thread Sterling
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

[PHP] Pattern Replacing

2001-03-29 Thread Sterling
H- Well here's a pattern replace issue which I've been working on without success hence the post. 8^) I have a variable that has stuff in it (tree, bird, nest, )(yes there is a trailing space) What I'd like to do is strip off the last ', ' and replace it with a single space so that I have (tr