Haxe Forum > PHP and lastIndexOf
-
Esteve Jul 31 at 13:18
Hi all,
I think the PHP implementation of the String.lastIndexOf function is not consistent with the rest of technologies. The PHP is as followsfunction _hx_last_index_of($s, $value, $startIndex = null) { $x = strrpos($s, $value, $startIndex === null ? null : strlen($s) - $startIndex); if($x === false) return -1; else return $x; }
So the startIndex parameter refers the end of the string while it should refer the begining of the string as other implementations. The 3rd argument of the php function strrpos wants the position to start counting, from the start of the string. Hence the operation
strlen($s) - $startIndex
is not adequate and it should be simply:$x = strrpos($s, $value, $startIndex);
Is it actually a bug or I'm missing something? By the way, congrats for this so useful platform I'm just starting to use. -
Reported so they can check and add unit test
http://code.google.com/p/haxe/issues/detail?id=1111&thanks=1111&ts=1343780245 -
Thank you for the report, it has been fixed on SVN: http://code.google.com/p/haxe/source/detail?r=5211
Simon