|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-07-27 22:01 UTC] david dot nqd at gmail dot com
Description:
------------
This is not a bug report like #38337.
Shouldn't the return type of explode be restricted to an array given valid inputs (strings)?
This would mean that if an empty string was passed as the delimiter, the return would be an array containing individual characters.
I doubt this would break any existing code unless people used explode to check that the delimiter === ''
Reproduce code:
---------------
<?php
$x = explode('', 'abc');
?>
Expected result:
----------------
$x = array('a','b','c')
Actual result:
--------------
$x = false
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 29 18:00:01 2025 UTC |
Note that if explode('', 'abc') were implemented the correct result would actually be array('', 'a', 'b', 'c', ''), which would be unexpected to many people. To avoid confusion PHP does not allow this usage.