Array ( [0] => Array ( [OPT] => 65 ) )
how to get 65
to a variable in PHP
help me please....
Array ( [0] => Array ( [OPT] => 65 ) )
how to get 65
to a variable in PHP
help me please....
$arr = array(array('OPT'=>65)); // the array
echo $arr[0]['OPT']; // will print 65
$variable = $arrayname[0]['OPT'];
there are plenty of useful information for the beginners in the official manual.
In all simplicity:
$foo = array(array('opt'=>65));
$bar = $foo[0]['OPT'];
I suggest you familiarize yourself with the basics of PHP and the excellent language reference provided by PHP.net.
To prevent warnings, get value only if $arrayname[0]['OPT'] exists. If not - $variable will store default value - 0.
$variable = isset($arrayname[0]['OPT'])?$arrayname[0]['OPT']:0;
Try this:
<?php
$test= array ('0' => Array ( 'OPT' => 65 ) );
foreach($test as $val1) {
foreach($val1 as $val2) {
echo $val2;
}
}
?>