Regex implementation in any text files (using PHP)

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
me_suzy
Forum Newbie
Posts: 1
Joined: Fri Jun 03, 2016 8:53 am

Regex implementation in any text files (using PHP)

Post by me_suzy »

hi friends, I am trying to do a code by which to execute a command "regex" in php who seek and modify any text files

What does this code: select files, then I made a prag_match function to insert any Regex sintax. But if you verify the entire script in localhost, I got an error, something is not right.

here my entire code http://codepad.org/aCwOfRRD

The regex in preg_match I don't know why not work. I quote from the link above, the next piece of code that I think is wrong:
$file_list = get_list_dir($path_file, false, 'file', true, $excluded_file);

preg_match('/(\d+)/', $file_list, $matches);

print_r($matches);
But first please run in localhost the entire code from the link above to see the error.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Regex implementation in any text files (using PHP)

Post by requinix »

1. How about you tell us what the error message says? Because having us guess that it's about an array-to-string conversion is awkward.
2. $file_list is an array. You cannot pass it to preg_match() like that because the function only works on a string.

Can you give us an example of what you are trying to do? Because your explanation doesn't make sense to me.
Post Reply