Problem:
How to return array as result from php function?Solution:
Create a multiple or single key pair value array and return it from function and store in a variable.Example:
<?php
function my_arr_ret(){
$result = array(
'nm' => 'mynm',
'id' => 'myid',
'amount' => 12345.89,
'code' => 'mycode'
);
return $result;
}
$my_arr=my_arr_ret();
echo $my_arr['amount'];
?>
0 comments:
Post a Comment