PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Thu Oct 19, 2017 2:07 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Mon Sep 18, 2017 5:46 pm 
Offline
Forum Contributor

Joined: Wed Jan 18, 2017 4:43 pm
Posts: 162
Php programmers,

Can you see why the script is unable to find the banned words that exist on the page ? It is a puzzling incident!

Syntax: [ Download ] [ Hide ]
<?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, 'https://www.buzzfeed.com/mjs538/the-68-words-you-cant-say-on-tv?utm_term=.xlN0R1Go89#.pbdl8dYm3X');
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("Prick","Dick","Fag");
 
    //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);
 


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: Bing [Bot] and 12 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group