Uzytkownik "Andy Hassall" <an**@andyh.co.uk> napisal w wiadomosci
news:oo********************************@4ax.com...
On Sat, 11 Oct 2003 00:07:39 +0200, "lecichy" <co*****@vline.pl> wrote:
Heres the situation:
I got a file with lines like:
name:second_name:somenumber:otherinfo
etc with different values between colons ( just like passwd file)
What I want is to extract some part of it like all names or numbers from
each line, simply text fom between e.g. second and third colon. And turn
itinto array so that I can later operate on these strings.
$array = explode(':', $line);
http://php.net/explode
And second, variation of it:
To get whole lines that contain some characters like 3 digits from a
numbersecond b) :)
to extract only nmbers with some digits not whole lines.
Could you restate that more clearly; probably useful to show an example.
--
Andy Hassall (an**@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)
explode's fine but what if text pieces like name, number, in the line are
not separated by colons only but different chars like:
"name:address;number\otherinfo"
i I want to get a list of numbers only so the string from field between ";"
and "\" . Generally, we could say that the problem is abaut extracting a
string from between specified chars. Like finding sentences with exclamation
mark in some text ( so string from between chars "." and "!" )
About the second
we got lines like:
John:Anderson;6305912\single
Anna:Smith;6302678\married
Mark:Smith;6540945\married
and i want to print all lines with Smith. (I input Smith and get second and
third line printed ) so what I mean here is to print a line with exact
match.
Second, to print whole number filelds (only ) witch partial match. So
whole number that starts with some digits. In otherwords I put "630" in the
form and i want to get 6302678, 6305912 printed.
Gosh.. I mixed it up. I barely understand what I want so feel free to give
up on me :)