Tutorial: Solve PHP function split() is deprecated
To solve the deprecated warning (occurring since PHP 5.3) with the split function you have two possibilities, depending what you try to split with the built-in function.
Simple string splitting
<?php
$splitted = split(':', 'username:password');
// Replace it like that
$splitted = explode(':', 'username:password');
In the most cases you try to split by a simple string, then you could replace the current split with explode (fastest possibility).
Splitting by regular expression
<?php
$splitted = split(':', 'username:password');
// Replace it like that
$splitted = preg_split('/[s]+/', 'Another simple replacement');
In case you split a string not by a simple string but instead by a regular expression you could use the preg_split.
If you have further questions: Just use the comments section below.
Check out more helpful PHP tutorials or share this page on social media to help others.
Published by David on 23rd January, 2014
Would you like to follow BWF or like it? Click here!