Last active
August 29, 2015 14:26
-
-
Save khsk/dc3e1612f43a25b83cb1 to your computer and use it in GitHub Desktop.
foreach($array as $key => $array) 時の動作 ref: http://qiita.com/khsk/items/ea22c035232123804303
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
key: A array: a | |
array[key]: a | |
string(1) "a" | |
key: B array: 100 | |
array[key]: | |
int(100) | |
key: C array: 1 # true は出力で1 | |
array[key]: | |
bool(true) | |
bool(true) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
array: a | |
string(1) "a" | |
array: 100 | |
int(100) | |
array: 1 | |
bool(true) | |
bool(true) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
key: 0 array: a | |
array[key]: a | |
string(1) "a" | |
key: 1 array: 100 | |
array[key]: | |
int(100) | |
key: 2 array: 1 | |
array[key]: | |
bool(true) | |
bool(true) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
key: 0 array: a | |
array[key]: a | |
string(1) "a" | |
key: 1 array: b | |
PHP Notice: Uninitialized string offset: 1 in /tmp/foreach4.php on line 47 | |
array[key]: | |
string(1) "b" | |
key: 2 array: c | |
PHP Notice: Uninitialized string offset: 2 in /tmp/foreach4.php on line 47 | |
array[key]: | |
string(1) "c" | |
string(1) "c" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$array = array('A' => 'a', 'B' => 100, 'C' => true); | |
foreach ($array as $key => $array) { | |
echo "key: " . $key . " array: " . $array . "\n"; | |
echo "array[key]: " . $array[$key] . "\n"; | |
var_dump($array); | |
} | |
var_dump($array); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$array = array('A' => 'a', 'B' => 100, 'C' => true); | |
foreach ($array as $array) { | |
echo "array: " . $array . "\n"; | |
var_dump($array); | |
} | |
var_dump($array); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$array = array('a', 100, true); | |
foreach ($array as $key => $array) { | |
echo "key: " . $key . " array: " . $array . "\n"; | |
echo "array[key]: " . $array[$key] . "\n"; | |
var_dump($array); | |
} | |
var_dump($array); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$array = array('a', 'b', 'c'); | |
foreach ($array as $key => $array) { | |
echo "key: " . $key . " array: " . $array . "\n"; | |
echo "array[key]: " . $array[$key] . "\n"; | |
var_dump($array); | |
} | |
var_dump($array); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment