0

I have a text file, I am parsing it using a regex and saving in the table, is shows me Notice: Array to string conversion in /opt/lampp/htdocs/parsermine/index.php on

the regex is

preg_match_all('/([0-9]{1,3}.){3}[0-9]{1,3}/', $line, $matches); var_dump($matches[0]);

and dump is

array(1) { [0]=> string(11) "192.168.1.2" } 
array(1) { [0]=> string(11) "192.168.1.2" } 
array(1) { [0]=> string(11) "192.168.1.2" } 
array(1) { [0]=> string(11) "192.168.1.2" }

help me to sort out the problem

6
  • 4
    Possible duplicate of Notice: Array to string conversion in C:\xampp\htdocs\example\echo.php on line 8 Array Commented Aug 25, 2017 at 5:41
  • I didn't have that notice, I'm using PHP 7. Are you sure this is what triggered the notice, and why a notice should be a problem? just saying Commented Aug 25, 2017 at 5:47
  • 1
    Which line of index.php does the error message point to? What is on that line? What is $line? Is it a string or an array? Commented Aug 25, 2017 at 6:04
  • I can't even replicate the problem. If $line is an array you get a fatal warning saying preg_match needs two strings one array is given. If the $line is a string then all works as it's supposed to. And I don't understand the dump. It returns four arrays like that. I can't make that happen either. There must be more code that is causing the problem that we don't see. Commented Aug 25, 2017 at 6:58
  • Actually I want to display the dump in a column of html table, and it displays the notice over there. <td><?php print $matches[0]" <br> "."\n";?></td> Commented Aug 25, 2017 at 7:04

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.