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

How to make center align child div

 How to make center align child div?   Suppose you have 2 Div tag. And want the make inner tag center <div id="d1">      ...

Ads Inside Post

Powered by Blogger.

Arsip