Как сделать вывод статьи, ну допустим, как на хабре? То есть часть статьи(какое то количество символов), а потом "Читать полностью...".
class Parser
{
public static function factory($url)
{
$url = Functions::getRealUrl($url);
$className = static::getParserClassName($url);
$instance = new $className($url);
if (!($instance instanceof Parser_Interface)) {
throw new Exception("{$className} must implement Parser_Interface");
}
return $instance;
}
}
$parser = Parser::factory('https://toster.ru/q/286564');
$parser->getTitle();
$parser->getBody();
$sourceStream = fopen("/path/to/source.txt", "r");
$yesFileStream = fopen("/path/to/yes_keys.txt", "w");
$noFileStream = fopen("/path/to/no_keys.txt", "w");
if ($sourceStream && $yesFileStream && $noFileStream) {
while (($buffer = fgets($sourceStream, 4096)) !== false) {
$key = trim($buffer);
$data = file_get_contents('http://mydomain.com/search.php?k=' . urlencode($key));
if (strpos($data, 'yes') !== false) {
fwrite($yesFileStream, $key . PHP_EOL);
} else {
fwrite($noFileStream, $key . PHP_EOL);
}
}
fclose($sourceStream);
fclose($yesFileStream);
fclose($noFileStream);
}
$mergedArray = array();
foreach($array1 as $key=>$value) {
if (!is_array($mergedArray[$key])) {
$mergedArray[$key] = array();
}
$mergedArray[$key][] = $value;
}
foreach($array2 as $key=>$value) {
if (!is_array($mergedArray[$key])) {
$mergedArray[$key] = array();
}
$mergedArray[$key][] = $value;
}