Skip to content

Instantly share code, notes, and snippets.

@mhulse
Created February 7, 2012 19:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mhulse/1761490 to your computer and use it in GitHub Desktop.
Save mhulse/1761490 to your computer and use it in GitHub Desktop.
PHP arrays: Ending comma [simple] test...
2
foo => hello
bar => world
hello,world
Array
(
[0] => foo
[1] => bar
[2] =>
)
<?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