php - How to echo an array -
it's not i've never done before, reason won't work time... i'm returnin array function
//call function create result array $specs = givedata(); and i'm trying output data echo way:
<b>lenght:</b><?php echo $specs[0]['lenght']; ?> i tried var_dump , shows me data in array, print_r works.
edit: updated code way works me.
print values of array
<?php echo '<pre>'; print_r($specs); // or var_dump variable type (string / int / etc) var_dump($specs); echo '</pre>'; ?> the echo of pre tags formatting reasons in html since pre tag show linebreaks (\n) visible new line inside of html.
as echoing single value array, have refernce key doing.
echo $specs['length']; you can make sure key exists using function isset.
if(isset($specs['length'])) { echo $specs['length']; }else{ echo 'error, length not found'; } the functions used in answer can found on php.net website var_dump(), print_r() , isset()
Comments
Post a Comment