Advanced array


#1

please help






<?php
// This is an array using integers as the indices...
$myArray = array(2012, 'blue', 5, 'BMW');

    // ...and this is an associative array:
    $myAssocArray = array('year' => 2012,
                    'colour' => 'blue',
                    'doors' => 5,
                    'make' => 'BMW');
        
    // This code will output "blue".
    echo $myArray[1];
    echo '<br />';
        
    // Add your code here!
             echo"I have a '. $myAssocArray['year'].' ' . $myAssocArray['make'].'It is '. $myAssocArray['colour'].' and has'. $myAssocArray['doors'].' doors.";
             echo "I have a '. $myArray[0].' '. $myArray[3].'It is '. $myArray[1].'and has'. $myArray[2].' doors.";
  ?>
</p>



#2

The problem is in your echo statements, you have opened with double quotes " and continued with single quotes '. When you replace with single quotes it works fine. Each piece of data echo'ed is separate you don't need to think of it all be one text statement to be wrapped.

Try these lines:
echo 'I have a ' . $myAssocArray['year'] . ' ' . $myAssocArray['make'] . ' It is ' . $myAssocArray['colour'] . ' and has' . $myAssocArray['doors'] . ' doors.';
echo 'I have a '. $myArray[0].' '. $myArray[3].' It is '. $myArray[1].'and has'. $myArray[2].' doors.';