• Revista PROGRAMAR: Já está disponível a edição #53 da revista programar. Faz já o download aqui!

Sign in to follow this  
Followers 0

[PHP]Quotes bash.org

1 post in this topic

Uma função para tirar a quote nr tal ou uma random.

function bash_get($arg){
if(empty($arg)) $file=file_get_contents("http://bash.org/?random");
	if(is_numeric($arg)) $file=file_get_contents("http://bash.org/?".$arg);
	else return "bash.org: Invalid quote id.";

', '', $file);
preg_match("/<p class=\"qt\">(.*)<\/p>/", $file, $quote);
preg_match("/<a href=\"\?(.*)\" title=\"Permanent link to this quote\.\">/", $file, $id);
if(!$quote) return "bash.org quote not found.";
else return "bash.org quote #<b>$id:</b><br />$quote";



Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
Followers 0