Code to replace the last occurrence of a string in a string using PHP <?php function str_lreplace ( $search , $replace , $subject ) { $pos = strrpos ( $subject , $search ); print $pos ; if ( $pos !== false ) { $subject = substr_replace( $subject , $replace , $pos , strlen ( $search )); } echo $subject ; return $subject ; } str_lreplace( 'hello' , 'world' , 'this is hello world for checking hello when hello' ); ?> output :
This blog is about solutions for PHP,Python,JavaScript,j query,HTML,CSS and Ubuntu.