the_oliver Posted August 21, 2007 Share Posted August 21, 2007 Hello, I found a snippit of code, and im not sure what it does/how it works!: $code = explode("£$@", $comp_code); echo $code[0] . $i_titl . $code[1]; Where $comp_code is something like <some code>£$@</some code>. and $i_titl is a string of text. Can anyone explain a little please? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/66036-what-does-this-do/ Share on other sites More sharing options...
hostfreak Posted August 21, 2007 Share Posted August 21, 2007 Have you looked at the manual, http://php.net/explode It seems pretty straight forward what it is doing. Quote Link to comment https://forums.phpfreaks.com/topic/66036-what-does-this-do/#findComment-330251 Share on other sites More sharing options...
GingerRobot Posted August 21, 2007 Share Posted August 21, 2007 I dont suppose i can explain this any better than the manual can: www.php.net/explode I guess ill try anyway The explode function splits a string by whatever you put in the first parameter(the delimiter). It creates an array of all the pieces of the string between all delimiters found within the string. In your exact example: <?php $comp_code = '<some code>£$@</some code>.'; $i_titl = 'foo bar'; $code = explode("£$@", $comp_code); echo $code[0] . $i_titl . $code[1]; //produces <some code>foobar</somecode>. ?> Beaten to it, thought id post with the example using the posted code. Completely agree that the manual explains it though. Quote Link to comment https://forums.phpfreaks.com/topic/66036-what-does-this-do/#findComment-330255 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.