PHP Tutorial : Strpos and Strrpos

Basic thing, strpos and strrpos are two php functions which are used to find the position of first and/or last occurrence in a string – word (usefull for example when you want to build a function to get file extension). I hear you saying enough talking, let me see the available examples :

<?php
//get first occurrence

$string = "this string";
$find = "i";

print strpos($string,$find);//should print 2


print strrpos($string,$find); //should print 8

?>
This entry was posted in Basic PHP and tagged , , , , . Bookmark the permalink.

One Response to PHP Tutorial : Strpos and Strrpos

  1. Pingback: XkiD | PHP Tutorial : Strpos and Strrpos | blog.xkid.ro

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>