String Function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

hansford
Forum Commoner
Posts: 91
Joined: Mon May 26, 2008 12:38 am

Re: String Function

Post by hansford »

actually mine needs a break; for when the string is found. DevNets is cleaner, less code.

Code: Select all

 
<?php
 
$haystack = file_get_contents("logs2.txt");
$hayarray = explode("\n", $haystack);
$needle = file_get_contents("files2.txt");
$needarray = explode("\n", $needle);
 
foreach($hayarray as $arg){
 
foreach($needarray as $val){
 
if(strpos($arg, $val) !== false) {
 
    echo "found: " . $val . "<br>";
    break;
}
}
}
?>
 
Post Reply