PHP’s built-in Web Server designed specifically for development and testing. Since PHP5.4, CLI SAPI comes with a built-in web server. A Built-in web server makes it easy to quickly try out some scripts without needing […]
JQuery Check if Element Exists
1 2 3 |
if ($('#myElement').length > 0) { // it exists } |
Check for Empty Elements
1 2 3 |
if($('#myDiv').is(':empty')) { // do something } |
JQuery Adding/Removing Class on Hover
1 2 3 4 |
$('#element').hover( function(){ $(this).addClass('hover') }, function(){ $(this).removeClass('hover') } ) |
Add text to an image with PHP
In this post I would like to show how you can add text to an image with PHP, GD Library. In this post, we will use an existing image and we will write text on it.The imagettftext() function will be used to write the text […]
Scroll to top JQuery
When you have web page too long, it is recommended to provide your users easy navigation mechanism.You we can provide it in many ways like fixed navigation at top and left or right navigation panels..etc. Here I am gonna […]
AngularJS – IsArray function
AngularJS isArray() is one of the useful ng function. This function is used to identify if a reference is array or not. This function return Boolean which means , it will return true if the reference is an array, return […]
How to change array keys from uppercase to lowercase?
The array_change_key_case() function changes all keys in an array to lowercase or uppercase. Syntax:
1 2 3 4 |
array_change_key_case(array,case); array - The array to work on CASE_LOWER - Default value. Changes the keys to lowercase CASE_UPPER - Changes the keys to uppercase |
Convert Comma Separated String into Array
1 2 3 4 5 |
<?php $str="foo,bar,baz,bat"; $arr=explode(",",$str); // print_r($arr); ?> |
PHP – Convert HEX to RGB
Below function takes hex code (e.g. #eeeeee), returns array of RGB values.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
function hex2rgb( $colour ) { if ( $colour[0] == '#' ) { $colour = substr( $colour, 1 ); } if ( strlen( $colour ) == 6 ) { list( $r, $g, $b ) = array( $colour[0] . $colour[1], $colour[2] . $colour[3], $colour[4] . $colour[5] ); } elseif ( strlen( $colour ) == 3 ) { list( $r, $g, $b ) = array( $colour[0] . $colour[0], $colour[1] . $colour[1], $colour[2] . $colour[2] ); } else { return false; } $r = hexdec( $r ); $g = hexdec( $g ); $b = hexdec( $b ); return array( 'red' => $r, 'green' => $g, 'blue' => $b ); } |