OwlService Posted September 5, 2012 Share Posted September 5, 2012 Hi all, My hosting company recently upgraded PHP and now I get an error saying Function split is now depreciated. Do you know what I need to do to fix the code below please? My original coder is no longer around Thank you. <?php $menu = <<<MENU <ul> <li><a href="/" title="Ely Museum homepage" accesskey="1">Home</a></li> <li><a href="/about/" title="All about Ely Museum">About Us</a></li> <li><a href="/information/" title="Visitor information for Ely Museum" accesskey="8">Visitor Information</a></li> <li><a href="/displays/" title="The displays at Ely Museum">Displays</a></li> <li><a href="/events/" title="The displays at Ely Museum">Events</a></li> <li><a href="/education/" title="Educational information abiut Ely Museum">Education</a></li> <li><a href="/contact/" title="Contact information for Ely Museum" accesskey="9">Contact</a></li> </ul> MENU; $lines = split("\n", $menu); foreach ($lines as $line) { $current = false; preg_match('/href="([^"]+)"/', $line, $url); if (substr($_SERVER["REQUEST_URI"], 0, 5) == substr($url[1], 0, 5)) { $line = str_replace('<a h', '<a id="active" h', $line); } echo $line."\n"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/268031-function-split-is-deprecated-in/ Share on other sites More sharing options...
spiderwell Posted September 5, 2012 Share Posted September 5, 2012 i think preg_split() is the alternative to use now Quote Link to comment https://forums.phpfreaks.com/topic/268031-function-split-is-deprecated-in/#findComment-1375532 Share on other sites More sharing options...
requinix Posted September 5, 2012 Share Posted September 5, 2012 explode() for simple string delimiters, preg_split() if you need regular expressions. Quote Link to comment https://forums.phpfreaks.com/topic/268031-function-split-is-deprecated-in/#findComment-1375537 Share on other sites More sharing options...
OwlService Posted September 5, 2012 Author Share Posted September 5, 2012 Thanks Guys. Explode worked just fine Quote Link to comment https://forums.phpfreaks.com/topic/268031-function-split-is-deprecated-in/#findComment-1375540 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.