For smart Primates & ROBOTS (oh and ALIENS ).

Blogroll

Thursday, February 12, 2015

return array from php function

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'];   
?>
Share:

0 comments:

Post a Comment

Multiple attribute passing in querySelectorAll

Multiple attribute passing in querySelectorAll     Here I am demonstrating code to how to pass multiple attributes in querySelectorAll. <...

Ads Inside Post

Powered by Blogger.

Arsip