The strpos() function allows you to parse strings in PHP.
strpos()
- https://www.php.net/manual/en/function.strpos.php
- https://www.w3schools.com/php/func_string_strpos.asp
strpos.php
<?php
$string = "Hello bill bob";
$testWord = "bob";
$position = strpos($string, $testWord);
echo $testWord." is at: ".$position;
echo "<br><br>";
$array = array("jim bob", "tim tom", "frank furter");
foreach($array as $name) {
if(strpos($name, "tom") == TRUE){
echo $name."<br>";
}
}
echo "<br>";
exec("ip address",$exec);
$searchTerm = "inet ";
foreach($exec as $line){
if(strpos($line,$searchTerm) == TRUE){
echo $line."<br>";
}
}
?>
Be the first to comment