PHP strpos()


Back to php.


moderator    (2009-09-22)

moderator

PHP strpos()

strpos() is a useful PHP function that will allow you to find the first occurency of a string in another string, a common error is to place the arguments like with the ereg() function :

Description:
int strpos ( string $haystack , mixed $needle [, int $offset ] )


Here is an example:
<?php

$mystring = 'abcdef';
$findme  = 'a';

$pos = strpos($mystring, $findme);

// Please now note the use of === to make the difference between 0 and false

if ($pos === false) {
    echo "The string '$findme' was not found in the string '$mystring'";
} else {
    echo "The string '$findme' was found in the string '$mystring' at position $pos";
}
 
// It is also possible to ignore the beginning of a string

$newstring = 'abcdef abcdef';
$pos = strpos($newstring, 'a', 1); // $pos = 7, not 0

?>




(more options below)

*ba76aa    (2009-10-21 18:11:28)
strpos() in PHP.net

All explained here :

ht*p://www.php.net/function.strpos


*df5696    (2010-01-18 15:49:36)
14 years ago

A lot of useful information about php tutorials


maradona    (2010-02-19 20:31:24)
PHP Tutorials

PHP Tutorials - all about PHP
ht*p://phpforms.net/tutorial/tutorial.html


*0debb5    (2010-02-26 18:33:41)
php form

strops is a good function, but php formis more effectively on my opinion!


*dukonu    (2010-12-07 10:40:59)
13 years ago

Hi abhinav here. iam o demo on php strpos


pwhjenny    (2012-10-11 11:59:29)
PHP strpos()

The strrpos() function finds the position of the last occurrence of a string inside another string.

Syntax:- strrpos(string, find, start)


See also


ficgs
More websites

You must register to see these links, as this is a collaborative page, then you may change the order of the links by clicking the icons before the titles.



admin
Other websites

The following links might be less relevant, please change their ranks if you find them useful.


  * Function- How To Use Strpos With PHP | JWRmedia.com
jwrmedia > lessons

 Nikolay Pavlov » Blog Archive » Coding Horrors: PHP’s *
npavlov.kodar > blog/?p=30

You need to enable javascript in order to use Simple...

 A JayWalker's Diary: PHP: * and the game of Booleans
blog.thejaywalker > 2009/05

 PHP : strpos - Find position of first occurrence of a string
thaicreate

 RE: [PHP] * act funny when searching for "]]>".... - Open Blu Host
openbluhost

 field.class. * error - Sigsiu.NET Forum
sigsiu > forum/index.

 PHP Tutorial - strpos
tizag

Five #1 is at position - 4 Five #2 is at position - 14 Five #3 is...
The position of 5 in our string was 4 The position of the second 5...

 eZ Issue Tracker: Issue #006649: Warning: PHP - * : Empty delimiter. - eZ Publish Project
issues.ez > 6649

function HandleDeleteCommentRequest(commentID){ if (true ==...
function LoadHistory(){ if(typeof(historymanager) !=...

 PhpDig.net - PHP - strpos
phpdig > ref/rn58re1190

and is designed to provide information about the PHP programming...

 Javascript equivalent for PHP's strpos
kevin.vanzonneveld > techblog/article/javascript equivalent for

 PHP: strpos - Manual
jp.php > function.strpos

A strpos modification to return an array of all the positions of a...
I found that whatever I was using as a test with strpos it came out...

 PHP strpos function
bradino

// We can search for the character, ignoring anything before the...
strpos -- Find position of first occurrence of a string...

 Rails for PHP Developers – Reference for PHP strpos in Ruby
railsforphp > reference/strings/strpos

Are you a PHP developer interested in the Ruby on Rails...
Looking for Rails or PHP web application development,...

 Webmaster Kitchen - Incorrect FALSE result for PHP’s * function
webmasterkitchen > article/incorrect false result for

So in this example, strpos() would return integer...

 PHP :: * To Define PHP SELF
bigresource

Strpos - Get The Position Of A String Without Case Being An...
Is there anyway I can get the position of a string without case...

 php strpos - CodingForums.com
codingforums > showthread.

 Detect singular and plural words inside string : php, strpos, detect, singular, plural, text, string
experts exchange > Web Development/Web Languages Standards

Subscribe now for full access to Experts Exchange and...
All Experts Exchange premium technology solutions are available to...

 Need help with php strpos issue? - Yahoo!7 Answers
au.answers.yahoo > question/index?qid=20071212162228AAhoNCe

Can you advice me a good web hosting suitable for an ecommerce...
Is it possible to get hired for an IT position with an Associates...

 Need help with php strpos issue? - KingPin's Forum
kpsforum > rss news/15009 need help

 Php: (strpos) Search for text in a string » Aknosis.com
aknosis > 2009/02/28

I will post later briefly about php and data types, if you have...
Automating MySQL Database Backups on the Command Line via...
!== confuse you? This tests for an actual boolean value of...

 PHP strpos
forums.digitalpoint > showthread.

 [PHP] * - Ultrashock Forums
ultrashock > forums/server side

 [PHP] strpos - Neowin Forums
neowin > forum/index.

 PHP: strpos - Manual
php5 > function.strpos.

 RE: [PHP] strpos error (I'm missing something obvious)
opensubscriber > message

opensubscriber is not affiliated with the authors of this message nor...
it returns the Boolean false, I should have been...

 PHP strpos
search.code head > F

 PHP Bugs: #37662: "Call to undefined function ()" when with strpos("r")
bugs.php > bug.



Response  
 

Guest name   (option)     Register
Please sum : 437 + two  




Trackbacks : If you talked about this article in your blog or website, you may instantly get a backlink 
There's no trackback at the moment.