spillage Posted April 17, 2008 Share Posted April 17, 2008 This is probally more of a Monday morning question. Just running through my book on using the split function with regular expressions. Using <?php $email = "[email protected]£49"; $arr=split ('\.|\@|\£', $email); while (list($key, $value)= each ($arr)) echo '|'.$value; ?>- But the 45 is shown as 49-. Have spent a while looking on google etc. But should it not show 40??? I'm sure you can tell I'm fairly new to this so if this is a daft question please dont give me to much of a verbal hammering. Thanks Link to comment https://forums.phpfreaks.com/topic/101531-splitting-string/ Share on other sites More sharing options...
kenrbnsn Posted April 17, 2008 Share Posted April 17, 2008 What "45"? You don't have a 45 in your string. The "-" is showing because you have a "-" after your PHP block and the browser treats that as text to be output to the screen. Also, if you just want to separate the items in the $arr array with "|", you can use the implode() function: <?php $email = "[email protected]£49"; $arr=split ('\.|\@|\£', $email); echo '|' . implode('|',split ('\.|\@|\£', $email)); ?> Ken Link to comment https://forums.phpfreaks.com/topic/101531-splitting-string/#findComment-519336 Share on other sites More sharing options...
spillage Posted April 17, 2008 Author Share Posted April 17, 2008 sorry that was a typo should be 49. Doh got slightly blurry eyes today and had to get about an inch away from my screen to see that. code and alchol really dont mix. Thanks :-\ Link to comment https://forums.phpfreaks.com/topic/101531-splitting-string/#findComment-519341 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.