> i have 2 problems in 2 dimensional array
>
> 1. how to declare global 2 dimensional array in php
> 2. how to pass 2 dimensional array in function as an
> arrgument

In the context of your questions, 2-Dimensional arrays are no different to
1-dimensional arrays.

All global vairables in PHP are stored in the predefined $GLOBALS
associative array, which is automatically global in scope. Each key of the
$GLOBALS array is a name of a global variable. For example, the following
code will print "Hello World":

<?php

    function setVarA ( $value ) {
        $GLOBALS['varA'] = $value;
    }

    function echoVarA ( ) {
        echo $GLOBALS['varA'];
    }

    $varA = "Hello";
    echoVarA( );

    setVarA ( " World");
    echo $varA;

?>

Passing an array to a function is no different passing a scalar variable:

<?php
    function countArray ( $arrayArgument ) {
        return count ($arrayArgument);
    }

    $array = array ('a', 'b');
    echo "The array has ". countArray($array) ." items.";
?>

Cheers,

Al

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to