How to find the the last occurrence of a substring in a string with PHP

1 Answer

0 votes
$s = "c++ c php javascript golang php nodejs";

$pos = strrpos($s, "php");
          
if ($pos != FALSE) {
    echo $pos . " " . $s[$pos];
}
else {
    echo "not found";
}
 
 

  
/*
run: 
 
28 p
 
*/
    

 



answered Feb 21, 2020 by avibootz
...