FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Find Strings (Tokens) in File and push them into an array - How?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Find Strings (Tokens) in File and push them into an array - How? [message #169620 is a reply to message #169618] Sun, 19 September 2010 14:21 Go to previous messageGo to previous message
Michael Fesser is currently offline  Michael Fesser
Messages: 215
Registered: September 2010
Karma:
Senior Member
.oO(aaaa)

>> The code could even be shortened a bit. My version would be:
>>
>> foreach ($files as $file) {
>> $text = file_get_contents($file);
>> preg_match_all('/\$__txt.+?;/', $text, $matches);
>> $tokens = array_merge($tokens, $matches[0]);
>> }
>
> foreach ($files as $file) {
> $text = file_get_contents($file);
> $matches = explode(' ', $text);
> $tokens = array_merge($tokens, $matches);
> }
>
> Same result, but easier (and shorter!) code. And I can even make it shorter:
> […]

Indeed, in this case. If the OP's files are really just a bunch of
tokens without any other content and he always wants the entire string,
then just splitting the entire file would be enough. But usually the
situation is at least slightly more complicated, for example when things
like '$__txt' and ';' are used as delimiters and what matters are the
strings between them.

Micha
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Advanced SQL injection complete tool pack(tutorials,scanners,admin finder,shells,md5)
Next Topic: Stats comp.lang.php (last 7 days)
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Sep 20 19:17:43 GMT 2024

Total time taken to generate the page: 0.04450 seconds