Forum Moderators: coopster

Message Too Old, No Replies

Extracting a number

         

Crump

6:00 am on Apr 22, 2006 (gmt 0)

10+ Year Member



Lets say I have some lines of text that looks like this:

DAVID 6.45 JOHN 5.32 MICHAEL 49.24
GREG 3.93 LUKE 2.24 GEORGE 20.42

They are columns, but they are not aligned perfectly. Say I wanted to write a piece of code that went in, and got the number next to Luke.

Can't use substr because the columns get distored. However, there will always be a bit of whitespace in between each column (a variable amount).

What is the best way to do it?

dreamcatcher

1:57 pm on Apr 22, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Maybe explode() [uk.php.net]?

dc

henry0

4:53 pm on Apr 22, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



"variable space"?

Are we speaking about getting this from an existing text or from a DB

hakre

3:56 pm on Apr 24, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Maybe preg_match_all() [php.net]?