Tag Archives | snippet
PHP function: get US state name by abbreviation

PHP function: get US state name by abbreviation

This is a state list I made for a website. I kept it just in case i ever needed it again, which i have. I figured it would probably help someone else out. It includes all states in the US and two “51st state” (Puerto Rico and Guam). There are some functions that return the […]

Read full story Comments { 0 }
PHP: Convert IP Range to CIDR

PHP: Convert IP Range to CIDR

Read first: PHP: Convert CIDR to ipaddress range PHP: check valid ipaddress or CIDR notation range This function work done with small IP range ex: 111.234.23.1 – 11.234.23.243 Solution 1 Example of usage: result: Array ( [0] => 121.0.47.0/32 [1] => 121.0.47.1/31 [2] => 121.0.47.3/30 [3] => 121.0.47.7/29 [4] => 121.0.47.15/28 [5] => 121.0.47.31/26 [6] […]

Read full story Comments { 1 }
PHP: check valid ipaddress or CIDR notation range

PHP: check valid ipaddress or CIDR notation range

This function checks for a valid IP address or CIDR notation address range. Example of usage:

Read full story Comments { 0 }
PHP: Convert CIDR to ipaddress range

PHP: Convert CIDR to ipaddress range

This function takes an IP address and CIDR netmask (e.g. 102.68.1.0/25), and calculate IP address range in that netblock. Example: result: array(2) { [0]=> string(10) “102.68.1.0” [1]=> string(12) “102.68.1.127” }

Read full story Comments { 0 }
PHP: Convert Hex Color to RGB, RGB to Hex Color

PHP: Convert Hex Color to RGB, RGB to Hex Color

Example 1: result: Array ( [red] => 0 [green] => 255 [blue] => 103 ) Example 2: result: 0,255,103 Example 3: result: 34,255,102 Example 4: result: Array ( [red] => 34 [green] => 255 [blue] => 102 ) Other function hex2rgb

Read full story Comments { 0 }
Function str_ireplace in PHP4

Function str_ireplace in PHP4

According to the document of PHP official website, http://php.net/str_ireplace str_ireplace (PHP 5) str_ireplace — Case-insensitive version of str_replace(). So, it’s only for PHP5+. In PHP4, we use this function below: Example 1: result: array(3) { [0]=> string(29) “If find and change are arrays” [1]=> string(92) “then str_ichange() takes a value from each array and uses […]

Read full story Comments { 0 }