array problem

Discussion in 'PHP' started by dizyn, Oct 31, 2009.

  1. #1
    
    	$arr[] = array("foo" => "bar", 12 => true);
    	
    	$arr[] = array("fo" => "ba");
    
    PHP:
    this code has following output:

    Array
    (
        [0] => Array
            (
                [foo] => bar
                [12] => 1
            )
    
        [1] => Array
            (
                [fo] => ba
            )
    
    )
    Code (markup):
    I wanted output like this:
    Array
    (
        [0] => Array
            (
                [foo] => bar
                [12] => 1
                [fo] => ba
            )
    
    )
    Code (markup):

     
    dizyn, Oct 31, 2009 IP
  2. astrazone

    astrazone Member

    Messages:
    358
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    33
    #2
    like this?

    $arr = array("foo" => "bar", 12 => true, "fo" => "ba");

    second way:

    $arr[foo] = "bar";
    $arr[12] = true;
    $arr[fo] = "ba";
     
    astrazone, Oct 31, 2009 IP