Page 1 of 1

Regex implementation in any text files (using PHP)

Posted: Fri Jun 03, 2016 9:11 am
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.

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

Posted: Fri Jun 03, 2016 7:38 pm
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.