Menu
Menu
DaniWeb
Log In
Sign Up
Read
Contribute
Meet
Search
Search
About 1,000 results for
strpos
- Page 1
Re: function search substr
Programming
Web Development
11 Years Ago
by knowill
strpos
();
Re: If String Present ....
Programming
Web Development
13 Years Ago
by diafol
strpos
() only returns a number (char pos) if present. The $source contains the text. You need to use something like substr() to extract a specific piece of file. Either that or use regex.
Re: Store last tweet ID of my followers which @mention me and have a hashtag.
Programming
Web Development
12 Years Ago
by diafol
strpos
() is quicker than preg_match(). See the php manual for examples: [url]http://www.php.net/manual/en/function.
strpos
.php[/url]
strpos()
Programming
Web Development
7 Years Ago
by malatamil
… it is inbetween should **remove &** only how to use
strpos
() for this scenario. can anyone help me to solve this.
strpos() expects parameter 1 to be string, array given in
Programming
Web Development
13 Years Ago
by dfaulted
…if ( (tep_not_null($module)) && (in_array(substr($module['id'], 0,
strpos
($module['id'], '_')) . '.' . substr($phpself, (strrpos($phpself, '.')+1)),…'] = 0; } } $module = substr($GLOBALS['shipping']['id'], 0,
strpos
($GLOBALS['shipping']['id'], '_')); if (tep_not_null($order->info['shipping_method…
Re: strpos() expects parameter 1 to be string, array given in
Programming
Web Development
13 Years Ago
by kylegetson
try casting it as a string. I would guess your $module['id'] is not a string, which likely means that even casting it, won't give you expected results (though it probably won't throw an error). you could try : [CODE] $pos =
strpos
( (string) $string, $find ); [/CODE]
Re: strpos failing to output FALSE!
Programming
Web Development
6 Years Ago
by rproffitt
… triple equal signs here. <?php echo 1,
strpos
("Hello world!","s")==FALSE, PHP_EOL;… echo 2,
strpos
("Hello world!","s")===FALSE, PHP_EOL;… echo 3,
strpos
("Hello world!","s")==0, PHP_EOL;…
strpos workig on line 1 but not on line 2
Programming
Web Development
10 Years Ago
by lewashby
… open file"); while(!feof($file)) { $line = fgets($file); if(
strpos
($line, "$email") !== false) { echo "There was a… match"; if(
strpos
($line, "$psswd") !== false) { echo "<br>…
strpos failing to output FALSE!
Programming
Web Development
6 Years Ago
by UI
It is said on the following link: **Using the
strpos
() function** **The
strpos
() function is used to search for a string or character…" ? I do not see this happening. <?php echo
strpos
("Hello world!","s"); ?>
Re: strpos Counts From Which Pos ?
Programming
Web Development
6 Years Ago
by UI
… next starting point. Like so: $numberedString = "1234567890123456789012345678901234567890"; $fivePos =
strpos
($numberedString, "5"); echo "The position of 5… in our string was $fivePos"; $fivePos2 =
strpos
($numberedString, "5", $fivePos + 1); echo "<br…
Re: strpos failing to output FALSE!
Programming
Web Development
6 Years Ago
by rproffitt
Worked for me. It returned a zero. How did I test that? `echo
strpos
("Hello world!","s")==0` Also works. (adding with edit. `echo
strpos
("Hello world!","s")==FALSE;`
strpos vs. preg_match
Programming
Web Development
18 Years Ago
by Atomical
…'s even worth it to try to code something with
strpos
. I was of the opinion that preg_match would be slower…) ) { $offset = 0; while ( $pos <= strlen($file) && ($pos =
strpos
($file,$find,$offset)) !== FALSE ) { //now we are on " or…
Re: strpos workig on line 1 but not on line 2
Programming
Web Development
10 Years Ago
by pixelsoul
The problem is each line in your file is returned by fgets as a string. The
strpos
stops on the first line/string. If you were to use file_get_contents it returns the file as one string rather.
Re: strpos failing to output FALSE!
Programming
Web Development
6 Years Ago
by cereal
….types.string.casting In your case you can write: $pos =
strpos
('Hello World!', 's'); if(FALSE !== $pos) { # success } else { # not found…
strpos Counts From Which Pos ?
Programming
Web Development
6 Years Ago
by UI
Hiya, http://www.tizag.com/phpT/php-string-
strpos
.php On the above link, it is stated: PHP Code: $… = "1234567890"; // 10 numbers from 1 to 0 $fivePos =
strpos
($numberedString, "5"); echo "The position of 5…
Re: strpos Counts From Which Pos ?
Programming
Web Development
6 Years Ago
by cereal
… to consider as alternative. If you open [php.net/
strpos
](http://php.net/
strpos
) you get **preg_match**, which would return only `$matches…
Re: strpos Counts From Which Pos ?
Programming
Web Development
6 Years Ago
by diafol
…be a bit of a pain. The examples on
strpos
also show a recursive UDF, which I've mangled… multi_strpos($needle, $haystack, $offset = 0, &$results = array()) { $offset =
strpos
($haystack, $needle, $offset); if($offset === false) { return $results; } else { …
Re: strpos vs. preg_match
Programming
Web Development
18 Years Ago
by Gary King
If you need to use preg_match() then use it. If
strpos
() can do the job, then use that. Does that answer your question? Your question wasn't really clear in your post.
Re: strpos - skip certain characters
Programming
Web Development
10 Years Ago
by diafol
You're comparing the wrong data. What happened to the
strpos
? $char = 3; $pos = -1; $out = ""; $r = array_filter(explode(&…quot;|", $array)); foreach($r as $v) { if($pos =
strpos
($v, $char, $pos+1)) !== false) { $out .= "Found at position…
Re: strpos - skip certain characters
Programming
Web Development
10 Years Ago
by ivanichi
… first post, $string = '101131110|101131110|'; and i get it, with
strpos
I find that position 3 at (5 and 15), if… to know how to ignore this character '|' when I use
strpos
so i get the position 3 at 5 and 14…
strpos function in reverse
Programming
Web Development
11 Years Ago
by tapuwa2002
I would like to find a method where i can find a character position in reverse.For example last "e" starting count in reverse. From example $string="Kelley"; $strposition=(
strpos
,'e'); it will give me position 1.
strpos - skip certain characters
Programming
Web Development
10 Years Ago
by ivanichi
… = '3'; $string = '101131110|101131110|'; $positions = array(); $pos = -1; while (($pos =
strpos
($string, $char, $pos+1)) !== false) { $positions[] = $pos+1; } $result = implode…
Re: strpos - skip certain characters
Programming
Web Development
10 Years Ago
by pritaeas
> Now, I want to know how to ignore this character '|' when I use
strpos
so i get the position 3 at 5 and 14. Remove the pipe from your string before finding the positions.
Re: strpos - skip certain characters
Programming
Web Development
10 Years Ago
by paulkd
…|101131110|'; $string = str_replace('|', '', $string); $positions = array(); $pos = -1; while (($pos =
strpos
($string, $char, $pos+1)) !== false) { $positions[] = $pos+1; } $result = implode…
Re: Multiple needles(values) in strpos ?
Programming
Web Development
12 Years Ago
by diafol
… suggestion!) states preg_match could be a cooler solution.
strpos
() is quicker, BUT looping
strpos
vs. preg_match would probably be slower. For an…
Multiple needles(values) in strpos ?
Programming
Web Development
12 Years Ago
by JACOBKELL
…. [CODE] $text = "blablavalueblabla"; $word = "value"; $pos =
strpos
($text, $word); if ($pos === false) { echo "You word is…
Re: Multiple needles(values) in strpos ?
Programming
Web Development
12 Years Ago
by diafol
[url]http://www.php.net/manual/en/function.
strpos
.php#107351[/url]
Re: Multiple needles(values) in strpos ?
Programming
Web Development
12 Years Ago
by JACOBKELL
…($needle)) $needle = array($needle); foreach($needle as $what) { if(($pos =
strpos
($haystack, $what))!==false) return $pos; } return false; } $pos = strpos_arr('sentence…
Problem in using strpos() ??
Programming
Web Development
11 Years Ago
by apanimesh061
… "/", if true store them in an array ! ... if (
strpos
($html->href, 'http://') <= 0) { array_push($urlarray, $link->…
Re: Problem in using strpos() ??
Programming
Web Development
11 Years Ago
by ko ko
str_pos() returns boolean (TRUE or FALSE). Should be if (
strpos
($html->href, 'http://') !== FALSE) { //there is http in the url, then do this statement // your code } Or use @diafol method.
1
2
3
17
Next
Last
Search
Search
Forum Categories
Hardware/Software
Programming
Digital Media
Community Center
Latest Content
Newest Topics
Latest Topics
Latest Posts
Latest Comments
Top Tags
Topics Feed
Social
Meet People
Forums
Top Members
Community Functions
DaniWeb Premium
Newsletter Archive
Markdown Syntax
Community Rules
Developer APIs
Connect API
Forum API Docs
Tools
SEO Backlink Checker
Legal
Terms of Service
Privacy Policy
FAQ
About Us
Advertise
Contact Us
© 2024 DaniWeb® LLC