Split is deprecated in PHP 5.3 - What can I use instead

Hi,

Still learning my way around PHP.  I'm using the PEAR XML-RPC to talk to a web service.  Just wrote my first client and when I test it, it runs fine, but throws the Split() function deprecated error.   I did a little research and I see that Split is disabled in PHP 6.  

So...If I wanted to change the RPC.php code to avoid using Split, what would be a good way to go?

Thanks
TURBOSHANAsked:
Who is Participating?
 
Beverley PortlockCommented:
split() has been replaced by preg_split()

http://uk2.php.net/manual/en/function.preg-split.php

0
 
leakim971PluritechnicianCommented:
Hello TURBOSHAN,

str_split ?
http://www.php.net/manual/en/function.str-split.php

Regards.
0
 
gr8gonzoConsultantCommented:
If you're splitting by a normal character or string (e.g. if you don't need regular expressions), then use explode()
0
 
Hube02Commented:
Split is part of the ereg family of functions and they are all removed as of PHP6, so you should make sure to replace these as well with the equivalent preg family function.

And like gr8gonzo said, if you're not actually using a regular expression to spit on you should be using explode(), it is much faster, it's always faster to use a simple string function than a regular expression function for simple things.
0
 
Ray PaseurCommented:
You know about the PHP online manual, right?  See the first lightbulb tip on this page:
http://us3.php.net/manual/en/function.split.php

It's all there in black and white, along with many useful developer examples.  A really great learning resource!  All the functions are documented online - just a click away.

best regards, ~Ray
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.