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

Posted on 2009-12-23
Last Modified: 2013-12-13

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?

Question by:TURBOSHAN
    LVL 34

    Accepted Solution

    split() has been replaced by preg_split()

    LVL 81

    Assisted Solution

    Hello TURBOSHAN,

    str_split ?

    LVL 34

    Assisted Solution

    If you're splitting by a normal character or string (e.g. if you don't need regular expressions), then use explode()
    LVL 18

    Assisted Solution

    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.
    LVL 107

    Expert Comment

    by:Ray Paseur
    You know about the PHP online manual, right?  See the first lightbulb tip on this page:

    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

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    Suggested Solutions

    As this topic comes over and over again in different forms, I've finally decided to write a short (yea, right...) article / tutorial about pagination with PHP with MySQL database. There are dozens of these kind of tutorials, I know - I wanted to mak…
    Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
    The viewer will learn how to dynamically set the form action using jQuery.
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now