From: [EMAIL PROTECTED]
Operating system: All
PHP version: 4.3.0RC2
PHP Bug Type: Feature/Change Request
Bug description: Strings as Arrays...
This is probably a strange feature request, but I think it should be given
a lot of thought, if it has not done so already.
The request is this:
strings should be treated as arrays of characters (which they are) when
given as the arguement for functions which work on arrays.
so for example:
function foo ($chr) {
echo $chr . "<br />\n";
}
$string = "bar";
array_walk($string,foo); would give the result:
b
a
r
Also, to be able to do this with strings:
$string = "fo";
$string{} = "o";
so that
$string == "foo" == TRUE
Also, another thing that comes up often, is when trying to do this:
$string = "foo";
foreach ($string as $i) {
echo $string ."<br />\n";
}
does not work, and you have to do:
$string = "foo";
for($i = 0;$i <= strlen($string);$i++) {
echo $string{$i} ."<br />\n";
}
like I said, give this some thought, perhaps toss it around on php-dev
etc..
- Davey
--
Edit bug report at http://bugs.php.net/?id=20893&edit=1
--
Try a CVS snapshot: http://bugs.php.net/fix.php?id=20893&r=trysnapshot
Fixed in CVS: http://bugs.php.net/fix.php?id=20893&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=20893&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=20893&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=20893&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=20893&r=support
Expected behavior: http://bugs.php.net/fix.php?id=20893&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=20893&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=20893&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=20893&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=20893&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=20893&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=20893&r=isapi