? Earlier 3 items total Later ?

On this page:?

Implement Error 447

There's a humorous pseudo-RFC which establishes HTTP Error 447 as "dropped in Pacific Ocean". Here's some PHP to implement it, if you'd like. Sends the right header, and even looks like a standard Apache 2 error page.

");
?>


Dropped in Ocean!






Dropped in Ocean!

The requested item was accidentally dropped in the Pacific Ocean while being transmitted to your computer, and cannot be displayed.
If you think this is a server error, please contact the webmaster.

Error 447

example.com

Apache/2.0.40 (Red Hat Linux)

Extensible search highlighting in PHP

Based on Dean's original Google Hilite, but refactored a bit to make it easy to add support for more search engines (currently supports some 20-odd major searches).

)([^<]+)?(\b'.$term.'\b)/i', $text)) {
        $matched = "Spoon!";
      } else {
        $mismatched = "Whoops";
      }
      if (!preg_match('/<.+>/',$text)) {
        $text = preg_replace('/(\b'.$term.'\b)/i','$1',$text);  
      } else {
        $text = preg_replace('/(?<=>)([^<]+)?(\b'.$term.'\b)/i','$1$2',$text);
      }
    }
    $query_terms = implode(" ", $query_array);
    $query_terms = htmlspecialchars(urldecode($query_terms));
    //If all terms matched, just tell them you did the highlighting.
    if($matched) {
      //Change this message if you like.
      $message = "

It seems you arrived at this page from a search engine. To help you find " . "what you were looking for, your search terms (\"$query_terms\") should " . "be highlighted with yellow backgrounds, like this.

"; $text = $message . $text; } elseif($mismatched) { //If only some or no terms matched, offer to repeat the search locally. $query = implode("+", $query_array); //Also change this message if you like. $message = "

It seems you arrived at this page from a search engine, but that some " . "or all of the terms you searched for (\"$query_terms\") aren’t in this page. Would you like to " . "try your search again using this site’s built-in search? It might be more accurate.

"; if($matched) { $message .= "

Any of your search terms which do appear in this page " . "should be highlighted with yellow backgrounds, like this.

"; } $text = $message . $text; } } return $text; } ?>

For Ray

In response to his question here, assuming your content is in a string called $content:

$num_paras = substr_count($content, '

'); switch ($num_paras) { case 1: $image = 'one.jpg'; break; case 2: $image = 'two.jpg'; break; case 3: $image = 'three.jpg'; break; default: $image = ''; break; }

? Earlier 3 items total Later ?