Page 1 of 1

Need code for seperating data from database

Posted: Wed Jan 13, 2010 8:21 am
by smartsambath
hi

Re: Need code for seperating data from database

Posted: Wed Jan 13, 2010 8:27 am
by aravona
smartsambath wrote:hi...
i need a php code that extract the following data

#*1582*TN_reg*12.30*3232*name*id*454*3545*#
is this how the code is within your database?

Re: Need code for seperating data from database

Posted: Wed Jan 13, 2010 8:31 am
by Marinusjvv

Code: Select all

$string = "1582*TN_reg*12.30*3232*name*id*454*3545";
$stuff = explode("*",$string);
This will break your string down into an array, so it will look like this:

Code: Select all

echo $stuff[0]; // = "1582"
echo $stuff[1]; // = "TN_reg"
etc...

Re: Need code for seperating data from database

Posted: Wed Jan 13, 2010 11:02 am
by snipered
If this how it looks:

Code: Select all

#*1582*TN_reg*12.30*3232*name*id*454*3545*#
Then Marinusjvv explode will obviously show the hash marks. In the array the first and last items will need to be ignored. You will also have to disregard if the * exists at the start and end.

Re: Need code for seperating data from database

Posted: Thu Jan 14, 2010 5:24 am
by Marinusjvv
Well then he can use

Code: Select all

$string = str_replace('#','',$string); // to remove hashes
$string = substr($string, 1, strlen($string)); // to remove first *
I guessed that he had some programming knowledge..