|
|
<?php $A[0] = 123; $A[1] = 3.14; $A[2] = "Hello"; for ( $i = 0; $i < 3; $i++ ) { print ( $A[$i] . "\n"); } print ("\n"); ?> |
Output:
123 3.14 Hello |
How to run the program:
|
|
Example:
<?php $A[0] = 123; $A[1] = 3.14; $A[2] = "Hello"; for ( $i = 0; $i < count($A); $i++ ) { print ($A[$i] . "\n"); } print ("\n"); ?> |
How to run the program:
|
Example:
<?php $A[0] = 123; $A[1] = 3.14; $A[2] = "Hello"; print_r( $A ); print ("\n"); ?> |
|
$A[0] = 123; $A[1] = 3.14; $B = $A; // Make a COPY of array A in B $B[0] = "ABC123"; // $B[0] is changed, but $A[0] is unchanged |
Example:
$A[0] = 123; $A[1] = 3.14; $B = & $A; // Make a reference of array A in B // B reference to the same array elements as A $B[0] = "ABC123"; // $B[0] is changed, but $A[0] is unchanged |
|
<?php $color["grass"] = "green"; $color["apple"] = "red"; $color["sky"] = "blue"; print_r( $color ); print ("\n"); ?> |
Comment:
|