Skip to content

Instantly share code, notes, and snippets.

@skunkbad
Created September 4, 2017 15:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skunkbad/158a4980a94ebb5798c6f1fd7f433089 to your computer and use it in GitHub Desktop.
Save skunkbad/158a4980a94ebb5798c6f1fd7f433089 to your computer and use it in GitHub Desktop.
Code for UniqueIdeaMan
<?php
/*
ERROR HANDLING
*/
//declare(strict_types=1);
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
// 1). $curl is going to be data type curl resource.
$curl = curl_init();
// 2). Set cURL options.
curl_setopt($curl, CURLOPT_URL, 'http://www.tcm.com/this-month/article/297159|0/Dirty-Harry.html');
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true );
// 3). Run cURL (execute http request).
$result = curl_exec($curl);
$response = curl_getinfo( $curl );
if( $response['http_code'] == '200' )
{
//Set banned words.
$banned_words = array("Dirty Harry","Callahan", "Clint Eastwood");
//Separate each words found on the cURL fetched page.
$word = explode(" ", $result);
//var_dump($word);
for($i = 0; $i <= count($word); $i++){
foreach ($banned_words as $ban) {
if (stripos($word[$i],$ban) !== FALSE){
echo "word: $word[$i]<br />";
echo "Match: $ban<br>";
}else{
echo "word: $word[$i]<br />";
echo "No Match: $ban<br>";
}
}
}
}
// 4). Close cURL resource.
curl_close($curl);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment