Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,855 questions

51,776 answers

573 users

How to output an array for debugging in PHP

6 Answers

0 votes
$arr = ["PHP", "Programming"];

echo "<pre>";
print_r($arr);
echo "</pre>";

/*
run: 
 
Array
(
    [0] => PHP
    [1] => Programming
)
 
*/

 



answered Jul 26, 2017 by avibootz
0 votes
$arr = ["PHP", "Programming"];

echo '<pre>' . print_r($arr, true) . '</pre>';

/*
run: 
 
Array
(
    [0] => PHP
    [1] => Programming
)
 
*/

 



answered Jul 26, 2017 by avibootz
0 votes
$arr = ["PHP", "Programming"];

header('Content-Type: text/plain; charset=utf-8');
print_r($arr);

/*
run: 
 
Array
(
    [0] => PHP
    [1] => Programming
)
 
*/

 



answered Jul 26, 2017 by avibootz
0 votes
$arr = ["PHP", "Programming"];

var_dump($arr); 

/*
run: 
 
array(2) { [0]=> string(3) "PHP" [1]=> string(11) "Programming" }
 
*/

 



answered Jul 26, 2017 by avibootz
0 votes
$arr = ["PHP", "Programming"];

var_export($arr); 

/*
run: 
 
array ( 0 => 'PHP', 1 => 'Programming', )
 
*/

 



answered Jul 26, 2017 by avibootz
0 votes
$arr = ["PHP", "Programming"];

echo var_export($arr, true); 

/*
run: 
 
array ( 0 => 'PHP', 1 => 'Programming', )
 
*/

 



answered Jul 26, 2017 by avibootz

Related questions

6 answers 359 views
1 answer 140 views
140 views asked Jul 29, 2017 by avibootz
1 answer 158 views
4 answers 274 views
274 views asked Sep 2, 2017 by avibootz
...