This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function commonValue ( $array ) | |
{ | |
$counted = array_count_values ( $array ); | |
arsort ( $counted ); | |
return ( key ( $counted ) ); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function facebook_fans ( $fb_page ) | |
{ | |
$data = json_decode( file_get_contents( "https://graph.facebook.com/" . $fb_page ) ); | |
echo $data->likes; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getSourceCode ( $website ) | |
{ | |
// The link to the website | |
$code_lines = file ( 'http://webite.com' ); | |
// Loop through the code and build string | |
foreach ( $code_lines as $line => $code ) | |
$lines .= "<strong>{$line}. </strong> " . htmlspecialchars( $code ) . "</ br>\n"; | |
return $lines; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getLatLong ( $postcode ) | |
{ | |
$pc = preg_replace ( '/\s/', '', $postcode ); | |
$pc = 'http://maps.google.com/maps/geo?q='.$pc.',+UK&output=csv&sensor=false'; | |
$result = explode ( ",", file_get_contents ( $pc ) ); | |
return array ( $result[ 2 ], $result[ 3 ] ); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getYouTubeKey ( $video ) | |
{ | |
preg_match ( '#\\?v=([^&]+)\\&#s', $video, $vid ); | |
if ( count ( $vid ) > 0 ) | |
{ | |
// The correct match is the second item in array | |
return $vid[ 1 ]; | |
} | |
else |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getTwitterAvatar ( $username ) | |
{ | |
$twitter_xml = simplexml_load_file ( "http://twitter.com/users/".$username.".xml" ); | |
return $twitter_xml->profile_image_url; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// My Birthday :) | |
$date_1 = new DateTime( '1989-06-15' ); | |
// Todays date | |
$date_2 = new DateTime( date( 'Y-m-d' ) ); | |
$difference = $date_2->diff( $date_1 ); | |
// Echo the as string to display in browser for testing | |
echo (string)$difference->y; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# setting the path of Admin suite unit tests | |
admin_units = "admin/tests/units" | |
desc "Testing all admin unit tests" | |
task :admin_units do | |
puts "Going to test all unit tests now....hold tight...." | |
tests = Dir.entries(admin_units) | |
tests.each do |file| | |
if file != '.' && file != '..' | |
units = Dir.entries("#{admin_units}/#{file}") |