Tuesday, October 10, 2017

String Position in PHP


<?php

$string = 'I am Thet Naing Win. This is PHP Testing and Word position Test. If you are insterested in PHP, please join us!';

$find = 'T';

$find_length = strlen($find);

$offset = 1;

while ($strpos = strpos($string, $find, $offset)){
  echo 'The Character <strong>'.$find. '</strong> is found at '.$strpos.'.</br>';
  $offset = $strpos + $find_length;

}

?>

No comments:

Post a Comment