[Users] strip_tail() string length?

Juha Heinanen jh at tutpro.com
Tue Jan 30 07:00:28 CET 2007


Brandon Armstead writes:

 >     I'm wondering what the easiest method would be to grab how long the RURI
 > is and strip based on that information... or would I have to actually use
 > regex, or is there an easier STRLEN() or LENGTH() operation?  Any ideas, or
 > is this something that could be implemented?  Thanks.

i too have been thinking that regex is an overkill for tests like
this:

if (uri=~"^sip:\+") ...

a php like substr function might be faster.  so instead of the above or

 > i.e. strip_tail(strlen($ru) - 2); ... or something like such.

how about

if (substr(uri, 0, 5) == "sip:+") ...

or

substr($ru, -2, 2)

by the way, i didn't notice == operator in the summary.  should i write
the above if as

switch(substr(uri, 0, 5)) {
  case "sip:+": ...
  default: ...
}

instead or is == supported?

-- juha




More information about the Users mailing list