String Extraction

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
User avatar
luketheduck
Forum Newbie
Posts: 18
Joined: Mon Apr 19, 2004 9:13 am
Location: Aylesbury, Bucks, UK

String Extraction

Post 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...
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

i think the explode() function will be your friend ;)

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

Mark
User avatar
luketheduck
Forum Newbie
Posts: 18
Joined: Mon Apr 19, 2004 9:13 am
Location: Aylesbury, Bucks, UK

Post by luketheduck »

Thanks a lot. Seems to be what I needed!
Post Reply