Printing more than one array using print_r or any other function in php



PHP Snippet 1:

var_dump( $array, $array2, $array3 );

PHP Snippet 2:

$array = array("Foo", "bar");
$array2 = array("Fizz", "Buzz");

var_dump( $array, $array2 );

PHP Snippet 3:

array(2) { [0]=> string(3) "Foo" [1]=> string(3) "bar" }
array(2) { [0]=> string(4) "Fizz" [1]=> string(4) "Buzz" }

PHP Snippet 4:

function logArrays() {
  $arrays = func_get_args();
  for ( $i = 0; $i < func_num_args(); $i++ )
    printf( "Array #%d is %s", $i, print_r($arrays[$i], true) );
}

logArrays( $array, $array2 );

PHP Snippet 5:

Array #0 is Array ( [0] => Foo  [1] => bar  )
Array #1 is Array ( [0] => Fizz [1] => Buzz )

PHP Snippet 6:

Array #0 is ["Foo","bar"]
Array #1 is ["Fizz","Buzz"]

PHP Snippet 7:

function  pre( $txt ) {
  print_r( [ '<xmp> ' , $txt ,' </xmp> ' ] );
   }