Created
February 7, 2012 19:46
-
-
Save mhulse/1761490 to your computer and use it in GitHub Desktop.
PHP arrays: Ending comma [simple] test...
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
2 | |
foo => hello | |
bar => world | |
hello,world | |
Array | |
( | |
[0] => foo | |
[1] => bar | |
[2] => | |
) |
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
<?php | |
ini_set('display_errors', 1); | |
ini_set('log_errors', 1); | |
error_reporting(E_ALL); | |
header('Content-type: text/plain'); | |
$a = array('foo' => 'hello', 'bar' => 'world',); | |
echo count($a) . "\n"; | |
foreach ($a as $k => $v) echo $k . ' => ' . $v . "\n"; | |
echo implode(',', $a); | |
$s = 'foo,bar,'; | |
echo "\n"; | |
print_r(explode(',', $s)); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment