Hi, from 4.3.0 it will be ok to use strcspn(), atm (int 4.2.3) it has 2 params. >From 4.3.0 it has up to four params. It the second pair is like in substr(). Start index can be given, or even start index and how much chars to be checked. The same behavior is true and for strspn() (starting 4.3.0) but for your case strcspn() is the function.
Andrey ----- Original Message ----- From: "Monte Ohrt" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, November 14, 2002 12:02 AM Subject: [PHP-DEV] strpos() suggestion > Hi, > > I had a little problem to solve today, and couldn't find any easy way to > do it without some extra steps slicing things up. > > What I wanted to do is take an arbitrary point in a string, and find the > position of the first '[' on the left of it, and the first ']' on the > right of it. > > Finding the ']' was easy, I use strpos() to find the first occurance of > ']' after my given point. > > Finding '[' however is not so easy. strrpos() was my first guess, but it > does not work like strpos() at all. There is no optional third > parameter, and on an unrelated note it only works with a single > character, not a string. inconsistant ;-) My best solution was to slice > the string at my point, then get the position of '[' with strrpos(). > > I'm not sure of the most intuitive way to solve this. One way would be > to add a feature to strpos(); if you supply a negative third parameter, > it gives you the position of the first occurance to the _left_ of that > point. I'm not sure if the number should represent the position from the > end or beginning of the string. Another way, add a third parameter to > strrpos() to start at a given point from the end of the string. > > I'd try submitting a patch, but I'm not sure of which way would be best, > and my C is a bit rusty, I'd probably do more damage than help ;-) > > Thoughts? > Monte > > > -- > PHP Development Mailing List <http://www.php.net/> > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, visit: http://www.php.net/unsub.php