Since array_combine actually just gives me undefined function errors, I use the following code that I found:

function array_combine_emulated( $keys, $vals ) {
 $keys = array_values( (array) $keys ); 
 $vals = array_values( (array) $vals );
 $n = max( count( $keys ), count( $vals ) );
 $r = array();
 for( $i=0; $i<$n; $i++ ) {
  $r[ $keys[ $i ] ] = $vals[ $i ]; 
 } 
 return $r; 
} 

This does the same thing, and in another script, works perfectly.

I've combined two arrays using:

$F= array_combine_emulated($_POST['A'], $_POST['B']);

If I print_r ($_POST), I'll get:

Array ( [A] => Array ( [0] => [1] => [2] => ) [B] => Array ( [0] => sometext [1] => someothertext [2] => ) => [submit] => submit )

But if I print_r ($F), I'll get:

Array ( [] => )

I know that Array[A][1][2][3] and Array[2] is empty. Could this be why? Not sure if it's needed, but the input values on my form look like this:

<input type="text" name="A[]">
<input type="text" name="B[]">

Can someone shed some light?

    perhaps you meant [man]array_merge/man to merge your arrays together....

      duckduckgoose wrote:

      Since array_combine actually just gives me undefined function errors...

      ...because you are not using PHP5. anyway, what are you ultimately trying to do here? you have two arrays coming in via POST. do you want to form a new array using A for the keys and B for the values? you form code does not really suggest that is what you are doing.

        Write a Reply...