<?php | |
class SearchFile | |
{ | |
private $files; | |
private $search; | |
private $results; | |
public function __construct($search, $files=array()) | |
{ | |
$this->search = $search; | |
$this->files = $files; | |
$this->execute(); | |
} | |
public function execute() | |
{ | |
foreach ($this->files as $file) { | |
if (file_exists($file)) { | |
$string = file_get_contents($file); | |
if (stristr($string, $this->search) == true) { | |
$this->results[] = $file; | |
} | |
} | |
} | |
} | |
public function getResults() | |
{ | |
return $this->results; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment