I made this function, the same result get printed twice. Any idea why? is it my function? I can't find anything wrong with it.
$valid is an array.
function validOutput($output, $valid, $name, $mirror){
foreach($valid as $e) {
if(strpos($output, $e) != false) {
echo '<br />' . $name . '<br />';
e开发者_Python百科cho '<textarea cols=100 rows=10>';
echo '[tab: Mirror' . $mirror . ']';
echo $output;
echo "</textarea>";
}
}
}
Please tell me if you see anything wrong with it, thanks.
Edit:
$valid = array("facebook", "fbcdn", "megavideo", "video", "videoweed", "4shared");
$valid
has two elements that are substrings of $output
Can you show some sample inputs? Maybe explain what the motivation behind the $valid
parameter is?
I don't know if that could be the problem, but strpos()
must be checked as === false
or !== false
, because strpos
could be 0
and it will be treated as false
.
Doc > http://php.net/manual/en/function.strpos.php
精彩评论