Re: Note Integration Question

From: Date: Sun, 18 May 2003 14:00:35 +0000
Subject: Re: Note Integration Question
References: 1 2  Groups: php.doc php.internals 
Request: Send a blank email to phpdoc+get-969353622@lists.php.net to get a copy of this message
Saying that arrays are strings does not help here... var_dump(array_merge(array('hello', 'world'), 'now', 'here', array('more', 'and more'), 1, true)); This prints out int(1) and bool(true) for the last two elements, which are not arrays. Strings are also not handled as arrays here, as otherwise their "elements" would end up being individual elements of the resulting array. So a string is handled as "one value" and not an array of chars. The right people to ask whether this behaviour is intended or not is internals@, cc-ing to them too... Goba
Steph cames in with a good remark : "strings are arrays" I didn't see that approach but it seems ok to me. Maybe just adding it in the example with a little comment (// you can also pass strings to this function) will make it less confusing then changing protos and so on.
Mehdi Achour (didou) and I are currently doing some note maintenance and including some of the notes into the documentation. He came across an interesting note on array_merge() " Not sure if this is a bug or an undocumented feature, but array_merge accepts not only arrays as parameters, check out this line: var_dump(array_merge(array('hello', 'world'), 'now', 'here', array('more', 'and more'), 1)); returns a nice single array containing all the values. " This does actually work, and returns an array of 7 values. Should this be documented and the prototype be changed to accept 'mixed' arguments instead of 'array' or is this more likely a bug or quirk that shouldn't be documented?


« previous php.doc (#969353622) next »