Hi Dirk,

> When calling
>     "array_slice($array, 0, (float)2);"
>     the resulting array is EMPTY.
> When using the right type
>     "array_slice($array, 0, (int)2);"
>     it works as expected.

i think this should print a warning like other array functions.
But i looked into the src and this looks more like a casting bug inside this
function.

$input = array('a', 'b', 'c', 'd', 'e');
var_dump(array_slice($input, 1, "1"));
var_dump(array_slice($input, 1, 1));
var_dump(array_slice($input, 1, (FLOAT)1));
var_dump(array_slice($input, 1, 1.0));

output:
array(1) {
  [0]=>
  string(1) "b"
}
array(1) {
  [0]=>
  string(1) "b"
}
array(0) {
}
array(0) {
}

So i think the float value isnt correct casted as int value here. Maybe
someone else
can proof this.

-- Marco

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to