Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,200,883 members, 7,976,290 topics. Date: Wednesday, 16 October 2024 at 02:02 AM |
Nairaland Forum / Science/Technology / Webmasters / Php Quiz: Loop Quiz (1280 Views)
Most Confusing And Simple Maths Quiz / Dhtml Quiz: How Will You Detect If A Browser Support Javascript From Php Code? / Very Easy Html/php Quiz :) (2) (3) (4)
(1) (Reply)
Php Quiz: Loop Quiz by Nobody: 11:13am On Aug 09, 2011 |
What the heck is wrong with this code? foreach($data as $info) { Hmm, letz see who cracks this first! |
Re: Php Quiz: Loop Quiz by ogzille(m): 6:49pm On Aug 09, 2011 |
hmmm, dunno but it seems there is an issue with converting the string to an array like that; it may give you a fatal error |
Re: Php Quiz: Loop Quiz by Nobody: 11:04pm On Aug 09, 2011 |
Actually, there is nothing wrong with the code, the only time you cannot do this kinda thing is: foreach($data as $info) { $info=explode("=",$info); $data[$info[0]]=$info[1]; } Notice that - i only replaced $post with $data => This will result into a logical error: Reason: When foreach starts, a copy of the original array is kept inside its 'pocket of the function', so that while the loop runs, it runs from the copy, your own attempt to make changes to the same array 'data' will not do anything, because at the end of the foreach, the original $data will the overwritten with the one inside the pocket. |
(1) (Reply)
Stream Live Videos On A Website / Get Free Domain Name For Ur Blog /website / !!!!!!!!!!!!!
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 6 |