Menu
Menu
DaniWeb
Log In
Sign Up
Read
Contribute
Meet
Search
Search
About 1,000 results for
strpos
- Page 1
strpos()
Programming
Web Development
8 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
14 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
14 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
7 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
11 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
7 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
7 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
7 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
19 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
11 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
7 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
7 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
7 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
7 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
19 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
11 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
11 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
12 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
11 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
11 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
11 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: strpos()
Programming
Web Development
8 Years Ago
by rubberman
I assume these are GET arguments from a browser URL? If so, then each of mr1, mr2, and mr3 content strings would be avaliable in your PHP $_GET variables. So $_GET["mr1"] would return '60,60,60,60,60'. Anyway, show your code.
Re: strpos()
Programming
Web Development
8 Years Ago
by diafol
Why is your site throwing out misformed url parameters in the first place? Misformed urls should only really come from direct maniulation by the user. Trying to rectify misformed params is a bit pointless: Validate the params - if they pass great, if not, let 'em know: "Stop being a dick with the url". :)
Re: strpos()
Programming
Web Development
8 Years Ago
by malatamil
thanks, this is for manual testing before separating the param values i have to remove & in values. i have to remove only ?mr1=60,60,60,60,60&mr2=90,90,9**&**0,90,90&mr3=30,30,30,30,30 before spliting the array
Re: strpos()
Programming
Web Development
8 Years Ago
by diafol
Check for the existence of each $_GET parameter and validate each one. I don't see why you have to mess around or be concerned with the position of '&'. If you must have all 3 params: if(isset($_GET['mr']) && isset($_GET['mr2']) && isset($_GET['mr3'])) ... Once that test is passed, validate each, e.g. with regex. If …
Re: Multiple needles(values) in strpos ?
Programming
Web Development
13 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
13 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
13 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
13 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
12 Years Ago
by apanimesh061
… "/", if true store them in an array ! ... if (
strpos
($html->href, 'http://') <= 0) { array_push($urlarray, $link->…
1
2
3
17
Next
Last
Search
Search
Forums
Forum Index
Hardware/Software
Recommended Topics
Programming
Recommended Topics
Digital Media
Recommended Topics
Community Center
Recommended Topics
Latest Content
Newest Topics
Latest Topics
Latest Posts
Latest Comments
Top Tags
Topics Feed
Social
Top Members
Meet People
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
© 2025 DaniWeb® LLC