ID: 34857
Comment by: ms419 at freezone dot co dot uk
Reported By: stochnagara at hotmail dot com
Status: Open
Bug Type: Feature/Change Request
PHP Version: 5.1.0RC1
New Comment:
I am trying to parse the output of "svnlook proplist -v" into an
associative array of property keys and property values:
$pattern = '/^ ([^ ]+) : ((?:\V|\v[^ ]|\v [^ ])+)/m';
if (false === preg_match_all($pattern, $subject, $matches))
{
// Error handling
}
return array_combine($matches[1], $matches[2]);
This works great, unless "svnlook proplist -v" finds no properties. In
that case, array_combine() returns false because array() === $matches[1]
and array() === $matches[2].
Consequently, I am forced to treat the case when "svnlook proplist -v"
finds no properties as a special case.
I wish array() === array_combine(array(), array()), as I assumed it
would.
Previous Comments:
------------------------------------------------------------------------
[2005-10-13 15:07:12] stochnagara at hotmail dot com
Description:
------------
Currently array_combine returns false and raises a warning if it is
used with two empty array and this is documented too.
This is quite inconsistent since combining two empty arrays is expected
to result in another empty array.
If there are so many BC arguments, then this function could be extended
with a third optional argument 'accept_empty' which allow the thing I
request.
P.S. Actually bug #29972 is almost the same and has been marked closed
so this could be a reopen of this bug.
Reproduce code:
---------------
<?php
var_dump (array_combine (array(), array()));
?>
Expected result:
----------------
array(0) { }
Actual result:
--------------
Warning: array_combine() [function.array-combine]: Both parameters
should have at least 1 element in C:\Program Files\Apache
Group\Apache2\htdocs\boroinvest\test.php on line 3
bool(false)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=34857&edit=1