$fp = fopen(“filename”, “a”);
if($fp) {
fwrite($fp, “aString”);
fclose($fp);
}
|
||||
|
$fp = fopen(“filename”, “a”); This shows how to Remove duplicate elements from array using the array_unique function <?php
$input = array(“a”=>”apple”, “pear”, “b”=>”apple”, “orange”, “melon”);
print_r($input);
$result = array_unique($input);
print_r($result);
?>
Find All Links on a Page
$html = file_get_contents(‘http://www.yahoo.com’);
$dom = new DOMDocument();
@$dom->loadHTML($html);
// grab all the on the page
$xpath = new DOMXPath($dom);
$hrefs = $xpath->evaluate(“/html/body//a”);
for ($i = 0; $i < $hrefs->length; $i++)
{ $href = $hrefs->item($i);
$url = $href->getAttribute(‘href’);
echo $url.’<br />’;
}
/* Automatically link Twitter usernames in WordPress*/
function twtreplace($content) {
$twtreplace = preg_replace(‘/([^a-zA-Z0-9-_&])@([0-9a-zA-Z_]+)/’,”$1<a href=\”http://twitter.com/$2\” target=\”_blank\” rel=\”nofollow\”>@$2</a>”,$content);
return $twtreplace;
}
add_filter(‘the_content’, ‘twtreplace’);
add_filter(‘comment_text’, ‘twtreplace’);
function isItAndroid() { $ua = strtolower($_SERVER['HTTP_USER_AGENT']); if(stripos($ua,’android’) !== false) return true; else return false; } php search engine features include: Easy to install and configure This makes for great search integration between different products on an existing website. More Info |
||||
|
Copyright © 2013 Getphp : PHP and MySQL resources - All Rights Reserved |
||||