Question: I need help with the todos /** * The following is an array in php. */ $loonyToons = array( Bugs Bunny, Claude Cat, Daffy Duck,
I need help with the todos /** * The following is an array in php. */ $loonyToons = array( "Bugs Bunny", "Claude Cat", "Daffy Duck", "Elmer Fudd", "Marvin the Martian", "Merlin the Magic Mouse", "Michigan J. Frog", "Pepe Le Pew", "Porky Pig", "Road Runner", "Sylvester", "Tweety Bird", "Wile E. Coyote", "Yosemite Sam", "Tasmanian Devil" ); /** * To access a variable stored in an array, I type the name of the variable, and * then the index in the array. You can set your own indices, but if you do not, * then PHP wall use the counting numbers, starting from zero. */ print ($loonyToons[0] . " "); //outputs the "first" element in the array...element zero. print (substr($loonyToons[1],0,2)); //outputs the first two letters of "Claude Cat". //print_r ($loonyToons); //the print_r will output the entire array. Uncomment this line, see what happens, then comment it back. //@TODO print "Marvin the Martian" as output, accessing his entry in the array. // YOUR CODE HERE echo " "; //give some space /** * The "foreach" statement will loop over the entire contents of an array, exectuing code. * This is the same as saying, "for every x in loonyToons, print ...", but I say * it backwards, and use the word "as". */ foreach ($loonyToons as $x) { print($x . " is a Loony Toon. "); } echo " "; //give some space /** * @TODO read about the function substr on the php documentation page (you get to find it this time). * Then, create a foreach loop, similar to the one above, but that only prints the name * of the loony toon if the name begins with the letter, "M". */ Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
