1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

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