Jump to content

What does this do?


the_oliver

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/66036-what-does-this-do/
Share on other sites

I dont suppose i can explain this any better than the manual can:

 

www.php.net/explode

 

I guess ill try anyway :P

 

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.

Link to comment
https://forums.phpfreaks.com/topic/66036-what-does-this-do/#findComment-330255
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.