Jump to content

string in php


kadamsurekha

Recommended Posts

hello!

i hav a string which will be like "abcd*pqrs*"

i want the "abcd" part to store separetely in 1 string and "pqrs" separetely.

 

i have written the code as follows:

 

 

<?

  $friendname=$_get["user"];//this will store tht strng (abcd*pqrs*)

  $x=0;

  for($i=0;$i<strlen($friendname);$i++)

{

    if($friendname[$i]=='*')

    {

        $str=substr($friendname,$x,$i-1);

        echo "$str";

        $x=$i+1;       

    }

       

}

?>

 

can any1 tell me what is wrong here??

or any other way to do it?

Link to comment
https://forums.phpfreaks.com/topic/55827-string-in-php/
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.