It is said on the following link:
Using the strpos() function
The strpos() function is used to search for a string or character within a string.
If a match is found in the string, this function will return the position of the first match. If no match is found, it will return FALSE.
Isn’t the following supposed to output to screen “FALSE” ? I do not see this happening.
<?php
echo strpos("Hello world!","s");
?>
Try using var_dump()
on the result.
Once someone showed me how to use var_dump() but now I have forgotten it as I read no tutorial on that.
Know of a good link ?
How-about you check what is wrong and then show me your result aswell as how you did the test ? Would be good learning curve for me.
http://php.net/manual/en/function.var-dump.php
Edit:
Have a look at the solution to this topic and especially note the four error statements at the top of the page.
I have a function like this
function positiveRand() {
$rand = intval(str_pad(abs(mt_rand()), 10, '0'));
return $rand;
}
And a benchmark like so
for ($i=0; $i++ < 1000;) {
$log[] = positiveRand();
}
But for some weird reason, this echoes no numbers
foreach ($log as $index => $num) {
if ($num != abs($num)) var_dump($num);
}```
When I explicitly inspect the arrays, I find some of them have negative values (which I intend to exclude) and that some of them have integers less than 10 chara…
1 Like
system
Closed
July 27, 2017, 7:03am
6
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.