In Java, we can use indexOf
and lastIndexOf
. Since those functions don't exist in PHP, what would be the PHP equivalent of this Java code?
if(req_type.equals("RMT"))
pt_password = message.substring(message.indexOf("-")+1);
else
pt_password = message.substring(message.indexOf("-")+1,message.lastIndexOf("-"));
This is the best way to do it, very simple.