Learning PHP and MySQL

Example 11-14 Using several functions together to extract a portion of a string

<?php
   $test_string
="testing  testing  Username:Michele  Davis";
   
$position=strpos($test_string,"Username:");

    
//add  on  the  length  of  the  Username:
   
$start=$position+strlen("Username:");

   echo  
"$test_string<br>";
   echo  
"$position<br>";
   echo  
substr($test_string,$start);
?>

Posted by on 08/18 at 05:58 PM

Next entry: Example 11-15 A simple echo of the timestamp

Previous entry: Example 11-13 Detecting whether a string is contained in another string

<< Back to main