Cli must allow @ or spaces in array keys. Replace the parse_str function to hand made function

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1280 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2014-04-21 18:47:15 +00:00
parent 3f72772aec
commit 6d50f264f5

20
cli.php
View File

@@ -202,11 +202,21 @@ class cli
// (Array management in CLI)
foreach ($argv as $key=>$arg)
{
$val = null;
parse_str ($arg, $val);
if (count ($val) === 1 && reset ($val) === "")
$val = $arg;
$argv[$key] = $val;
$pairs = explode('&', $arg);
foreach($pairs as $pair) {
@list ($name, $value) = explode ('=', $pair, 2);
if ($value === null)
{
$argv[$key] = $name;
}
else
{
if (! is_array ($argv[$key]))
$argv[$key] = array ();
$argv[$key][$name] = $value;
}
}
}
// Manage a parameter in the constructor of the class