Blog Details

how to get position from string in php


                                
                                    <h2>* <span style="text-decoration: underline;">PHP strrpos() Function :-</span></h2>
<ul>
	<li><span style="font-size: 13px;">The strrpos() function <strong>finds the position</strong> of the <strong>last occurrence of a string</strong> inside another string.</span></li>
</ul>
&nbsp;
<ul>
	<li><strong><a style="font-size: 13px;" href="http://www.w3schools.com/php/func_string_strpos.asp">strpos()</a></strong><span style="font-size: 13px;"> - Finds the position of the f<strong>irst occurrence of a string inside</strong> another string (case-sensitive)</span></li>
	<li><a style="font-size: 13px;" href="http://www.w3schools.com/php/func_string_stripos.asp"><strong>stripos()</strong> </a><span style="font-size: 13px;">- Finds the position of the <strong>first occurrence of a string inside</strong> another string (case-insensitive)</span></li>
	<li><strong><a style="font-size: 13px;" href="http://www.w3schools.com/php/func_string_strripos.asp">strripos()</a></strong><span style="font-size: 13px;"> - Finds the position of the <strong>last occurrence of a string inside</strong> another string (case-insensitive)</span></li>
</ul>
&nbsp;
<h2>Syntax :</h2>
<h3><strong>strrpos(<em>string,find,start</em>)</strong></h3>
<h2><strong>Example :</strong></h2>
&lt;html&gt;
&lt;body&gt;

<span style="color: #ff0000;">&lt;?php
echo strrpos("I love php, I love php too!","php");   //first occurance of a string</span>

<span style="color: #ff0000;">echo strpos("I love php, I love php too!","php");    //first occurance of a string</span>

<span style="color: #ff0000;">echo stripos("I love php, I love php too!","php");   //last  occurance of a string
?&gt;</span>

&lt;/body&gt;
&lt;/html&gt;
<h2>Output :</h2>
8

8

19
                                    


Categories

Core_PHP

Latest posts

13.05.14
Implementing CRUD Operations ¶

<ul> <li>Now comes the fun part. We would like t

13.05.14
View

<ol> <li><a href="http://www.yiiframework.com/do

13.05.14
Creating Model

<ol> <li><a href="http://www.yiiframework.com/do

Get Free Quote