actionscript 3 - Port lastIndexOf AS3 code to PHP -
i'm trying port as3 code php finds tags (hashtags) @ end of text block. i'm stuck @ part lastindexof
. how write in php?
as3:
var message = "lorem #ipsum dolor sit amet, consetetur #1tag #2tag #3tag" while (message.lastindexof(" ") == message.lastindexof(" #")){ message = message.slice(0,message.lastindexof(" ")); }
i tried code got error: unexpected 'while' (t_while)
php:
$message = "lorem #ipsum dolor sit amet, consetetur #1tag #2tag #3tag"; while (strrchr(" ",$message) == strrchr(" #",$message)){ $message = $message.substr(0,strrchr(" ",$message)); }
add ;
symbol @ end of next line:
$message = "lorem #ipsum dolor sit amet, consetetur #1tag #2tag #3tag"
and swap arguments in strrchr
functions.
strrchr(" ",$message) strrchr($message, " ")
Comments
Post a Comment