Page 1 of 1

String Extraction

Posted: Mon Apr 19, 2004 9:13 am
by luketheduck
This problem has been going round my brain all day.

What I have is a string in a database, holding details of players shown a yellow card in a football match. The string is held in a field called 'acards', in the format:

3|4|8 etc.

The '|' is a divider, and the numbers represent each player booked.

Now what I need to do is be able to extract the string, and then remove each number so that when I cycle through my 'for' loop of the team line-up, I can add a yellow card next to the appropriate players name. For example players 3, 4 & 8 from the above string.

The for loop and everything is all sorted nicely. What I need is to use some string formatting function to extract each number from the database. I just don't know the best way to do it!

This is my first post by the way...

Posted: Mon Apr 19, 2004 9:17 am
by JayBird
i think the explode() function will be your friend ;)

http://se.php.net/manual/en/function.explode.php

Mark

Posted: Mon Apr 19, 2004 9:32 am
by luketheduck
Thanks a lot. Seems to be what I needed!