Using split on PHP 5.3.0

It’s been a while since it started coding again in PHP specially in PHP 5.3.0 and I’ve come across some interesting finding, for example some functions such as ereg, eregi and split are deprecated now in favor of a new library call Perl-Compatible Regular Expressions. For old coders (like me) we need to start updating our code to keep with the up to date standards.

A function I use a lot (for good or for bad) is split but as a matter of fact is one of the new deprecated functions on php so instead of calling it as usual (delimiter, string) now we have to call it using a perl-compatible regular expression (regex,string) as follows:

$email = “something@domain.com”;

$parts = preg_split(‘/@/’,$email);

Result:

Array ( [0] => something [1] => domain.com )

You can see it’s the same result as the old split() function.

Hope this saves you some time.

VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)
Clip to Evernote

One thought on “Using split on PHP 5.3.0

  1. Keep a footprint of every one only thing happening which will help to attract vital trade for purchasing. Just rebuff who all visits sites and spends time on which serving-boy.Also consider the footing they selected to make purchases. This will help in gaining information about the interests of customers to get ready them exactly what they want.

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>