Array to string conversion error in PHP

Sometimes you got error Array to string conversion in PHP while displaying some data. Because you use echo statement instead of print_r() to display data.

Answers 1
  • Use print_r() instead of echo statement in php

    // Use 
    print_r($data);
    //Instead of 
    echo $data;
    
    0

    If there are array values in $data then you should use print_r() instead of echo statement in php to avoid error Array to string conversion error.

  • Back to code snippet queries related php