Jump to content

heuristic

New Members
  • Posts

    1
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

heuristic's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. 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 : [code] 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;       } } [/code] This is what i tried to do in php : [code] <?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 );      ?> [/code] Why doesnt this work?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.