Need code for seperating data from database

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
smartsambath
Forum Newbie
Posts: 1
Joined: Wed Jan 13, 2010 8:12 am

Need code for seperating data from database

Post by smartsambath »

hi
Last edited by smartsambath on Mon Sep 26, 2011 3:39 am, edited 1 time in total.
aravona
Forum Contributor
Posts: 347
Joined: Sat Jun 13, 2009 3:59 pm
Location: England

Re: Need code for seperating data from database

Post 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?
Last edited by aravona on Wed Jan 13, 2010 8:31 am, edited 1 time in total.
Marinusjvv
Forum Commoner
Posts: 29
Joined: Wed Dec 02, 2009 5:59 am

Re: Need code for seperating data from database

Post 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...
snipered
Forum Newbie
Posts: 2
Joined: Mon Apr 21, 2008 9:17 am

Re: Need code for seperating data from database

Post 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.
Marinusjvv
Forum Commoner
Posts: 29
Joined: Wed Dec 02, 2009 5:59 am

Re: Need code for seperating data from database

Post 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..
Post Reply