Re: Find Strings (Tokens) in File and push them into an array - How? [message #169544 is a reply to message #169541] |
Fri, 17 September 2010 13:04 |
DigitalDude
Messages: 7 Registered: September 2010
Karma:
|
Junior Member |
|
|
On 17 Sep., 14:31, matt <matthew.leonha...@gmail.com> wrote:
> On Sep 17, 8:17 am, DigitalDude <e.blumsten...@googlemail.com> wrote:
>
>> Just for the record: the parsing is not the problem, just how to get
>> the token from the file into my array. I need to copy each token that
>> matches a pattern (e.g. "$__txt" or so) and then save it as a string
>> into an array (which I would probably do with array_psuh or so).
>
> Sounds like you need regex:
>
> preg_match_all("/(\$__txt[^;]*);/", $fileTextString, $matches);
> print_r($matches);
>
> Not a complicated job to take structure of $matches and manipulate it
> to your needs.
>
> ref:http://us2.php.net/manual/en/book.pcre.php
Hey,
yeah that seems to be the right approach, although I get a lot of
emtpy arrays this way. I hope I can modify this to a working version,
I cannot believe it is so complicated to setup such a trivial
function...
|
|
|