Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.