PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
lipun4u
Forum Commoner
Posts: 82 Joined: Wed Jul 01, 2009 3:35 am
Location: Mumbai
Contact:
Post
by lipun4u » Mon Sep 14, 2009 3:53 am
Go through the following code..
Code: Select all
<?php
/*function println($s) {
echo "$s<BR>\n";
}*/
$countries = array ( "ca" => "Canada",
"cr" => "Costa Rica",
"de" => "Germany",
"uk" => "United Kingdom",
"us" => "United States"
);
while(list($key,$val) = each($countries)) {
echo "Element $key equals $val<BR>\n");
}
?>
It should print entire string indexed array. But why does it print the following ???
Code: Select all
3<BR>
2<BR>
0<BR>
9<BR>
4<BR>
6<BR>
lord_webby
Forum Commoner
Posts: 44 Joined: Wed Aug 19, 2009 9:01 am
Post
by lord_webby » Mon Sep 14, 2009 4:04 am
Code: Select all
<?php
$countries = array ( "ca" => "Canada",
"cr" => "Costa Rica",
"de" => "Germany",
"uk" => "United Kingdom",
"us" => "United States"
);
while(list($key,$val) = each($countries)) {
echo "Element $key equals $val<BR>\n";
}
?>
Outputs:
Element ca equals Canada
Element cr equals Costa Rica
Element de equals Germany
Element uk equals United Kingdom
Element us equals United States
lipun4u
Forum Commoner
Posts: 82 Joined: Wed Jul 01, 2009 3:35 am
Location: Mumbai
Contact:
Post
by lipun4u » Mon Sep 14, 2009 4:33 am
Though my code has some error, why the interpreter doesn't show these errors ??
lord_webby
Forum Commoner
Posts: 44 Joined: Wed Aug 19, 2009 9:01 am
Post
by lord_webby » Mon Sep 14, 2009 4:49 am
Code: Select all
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1); ?>
Include that on every page - you had an extra ")" at the end.
lipun4u
Forum Commoner
Posts: 82 Joined: Wed Jul 01, 2009 3:35 am
Location: Mumbai
Contact:
Post
by lipun4u » Mon Sep 14, 2009 6:15 am
thanx