PHP Classes

File: fwphp/glomodul/z_examples/book_video/03steinmetz_2008/ch05_txt_html/pos.php

Recommend this page to a friend!
  Classes of Slavko Srakocic  >  B12 PHP FW  >  fwphp/glomodul/z_examples/book_video/03steinmetz_2008/ch05_txt_html/pos.php  >  Download  
File: fwphp/glomodul/z_examples/book_video/03steinmetz_2008/ch05_txt_html/pos.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: B12 PHP FW
Manage database records with a PDO CRUD interface
Author: By
Last change:
Date: 3 months ago
Size: 623 bytes
 

Contents

Class file image Download
<?php
$string
= "I approve of Senator Foghorn's performance in the War on Buttermilk. My name is Ferrett Steinmetz, and I approved this message.";
$search_term = "approve";
// Does it appear in the string?
$pos = strpos($string, 'approve');
if (
$pos === False) {
    print
"$term not in string\n";
} else {
    print
"position: $pos\n";
    print
"last position: " . strval(strrpos($string, $search_term)) . "\n";
    print
strstr($string, $search_term) . "\n";
   
// prints "approve of Senator Foghorn's ... "
   
print substr($string, strrpos($string, $search_term)) . "\n";
   
// prints "approved this message."
}
?>

For more information send a message to info at phpclasses dot org.