0

i want to create new instance in the $shop array , something like this :

    list1 = array( "rose" , 1.25 , 15);
    $list2 = array("daisy", 0.75 , 25);
    $list3 = array("orchid", 1.15 , 7);
    $list4 = array("orchid1", 2.15 , 9);

    $shop = array( $list1 ,
                   $list2 ,
                   $list3 
                 );

 //something like the line bellow 
    $shop = $shop + array(array($list4));
    echo $shop[3][0];

when i execute this code , i'm facing this error msg :

Notice: Undefined offset: 3 in C:\xampp\htdocs\array.php on line 13

line 13 : $shop = $shop + array(array($list4));

thanks in advance ^^

0

1 Answer 1

4

If $list4 is already an array, then you don't need array(array()). The simplest and probably fastest way would be to do:

$shop[] = $list4;
//equivalent
$shop[] = array("orchid1", 2.15 , 9);
1
  • this is it , tnks buddy ^^ Commented May 13, 2013 at 0:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.