php print_r function


To display an array element in php you cannot use 'echo' function or 'print' function.To display an array elements in php we use another inbuilt function known 'print_r' using this function you can display the array elements.

<!DOCTYPE html>
<head><title>expertcodingmaster.com</title>
</head>
<body>
<?php
$example  =  array ('mukesh' , 'ankita' , 'prashant') ;
echo     "<pre>" ;
print_r ($example) ;
echo    "<pre>" ;
? > 
</body>
</html>
</html>

Output  screen
Array
(
    [0] => mukesh
    [1] => ankita
    [2] => prashant
)

No comments: