creating array from line of text

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
someguyhere
Forum Contributor
Posts: 181
Joined: Sun Jul 27, 2008 3:24 pm

creating array from line of text

Post by someguyhere »

I'm having a tough time figuring out how to take a string of text and turn it into an array. The items are delimited with a pipe; ex:

item1|item2|item3|item4

Can someone point me in the right direction?
someguyhere
Forum Contributor
Posts: 181
Joined: Sun Jul 27, 2008 3:24 pm

Re: creating array from line of text

Post by someguyhere »

NM

explode
indian98476
Forum Commoner
Posts: 78
Joined: Tue Dec 15, 2009 3:24 am

Re: creating array from line of text

Post by indian98476 »

just a small example to get u carrying on....

$goingtoexplode = "item1|item2|item3|item4";
$exploded = explode("|", $goingtoexplode);

//to print the values
echo $exploded[0]; //item1
echo $exploded[1]; //item2 and so on...
Post Reply