hi!
I am very new to php with a strong C/C++ background. I currently have a C code which i want to port to php. The code involves passing 2-d arrays into functions. Is it possible to do that in php ( I dont want to use associative arrays. i.e I want to use numerical subscripting for the arrays )
The C code is something like this :
void myFunc( int myArray[2][3] )
{
for( int i=0; i<2; i++ )
{
for( int j=0; j<3; j++ )
cout << myArray[i][j] << " ";
cout << endl;
}
}
This is what i tried to do in php :
<?php
function printArray( &$ar )
{
print("printArray");
print("<hr>");
for( $i=0; $i<2; $i++ )
{
for( $j=0; $j<3; $j++ )
{
$v = $ar[$i][$j];
print("$v ");
}
print("<br>");
}
print("<hr>");
}
$myarray[0][0] = 0;
$myarray[0][1] = 1;
$myarray[0][2] = 2;
$myarray[1][0] = 10;
$myarray[1][1] = 11;
$myarray[1][2] = 12;
printArray( $myArray );
?>
Why doesnt this work?