Archive | PHP

RSS feed for this section
PHP: detect Point in Polygon

PHP: detect Point in Polygon

PHP function to detect Point in Polygon: Test for convex polygon: Result: IN OUT Test for concave polygon: Result: OUT IN OUT Note: we only apply this method for simple polygon (non-self-intersecting polygon). Test for complex polygon (self-intersecting polygon) Result: OUT OUT OUT Error for point 2.

Read full story Comments { 0 }

PHP: Calculate Distance Between Two Coordinates

This routine calculates the distance between two points (given the latitude/longitude of those points). It is being used to calculate the distance between two locations: Example: Result: 423232.85930123 Note: Result as meters Ellipsoidal parameters: Name Major axis, a (km) Flattening (f) WGS84 6378.13700 1/298.257223563 GRS80/NAD83 6378.13700 1/298.257222101 WGS66 6378.145 1/298.25 GRS67/IAU68 6378.16000 1/298.2472 WGS72 6378.135 […]

Read full story Comments { 0 }

PHP: convert javascript escape string to CP1251

This function can convert javascript escape string to CP1251: Example 2: result: ຈະນານຸກົມພິເສດ Read more: PHP: convert javascript escape string to UTF8

Read full story Comments { 0 }
PHP: convert javascript escape string to UTF8

PHP: convert javascript escape string to UTF8

Read first: PHP: PHP: Convert Numeric Character Reference to UTF8 Example 1: U+0621: ARABIC LETTER HAMZA Java Escape: “\u0621” Javascript Escape: “\u0621” result: ء We can create this function below: Example 2: result: สารานุกรมเสรี Alternative function:

Read full story Comments { 0 }
PHP functions: remove accents, UTF8 to ASCII, latinization (part 2)

PHP functions: remove accents, UTF8 to ASCII, latinization (part 2)

Read first: PHP functions: remove accents, UTF8 to ASCII, latinization Usage: result: Regardez les videos YouTube – notamment celles proposees en Haute Definition (HD) – en toute convivialite sur grand ecran. result: Eti prodazhi polnostyu avtomaticheskie. Imeyushiesya ezhechasnye podpiski takzhe prodolzhayut rabotat. result: Cong hoa Xa hoi chu nghia Viet Nam Some simple table to […]

Read full story Comments { 0 }
PHP get image path from text

PHP get image path from text

Is it possible to get image path from some text using PHP ? For example, we have a text with such code somewhere inside it This text is stored in DB (as article). How to get image path (in this example it is – http://tutorialspots.com/wp-content/uploads/2013/04/1.png) from text? Of course, text and images varies from article […]

Read full story Comments { 0 }
PHP functions: remove accents, UTF8 to ASCII, latinization

PHP functions: remove accents, UTF8 to ASCII, latinization

There are many methods to remove accents, UTF8 to ASCII, latinization: Method 1 Using iconv function: result: Regardez les vidos YouTube – notamment celles proposes en Haute Dfinition (HD) – en toute convivialit sur grand cran. result: Regardez les vid’eos YouTube – notamment celles propos’ees en Haute D’efinition (HD) – en toute convivialit’e sur grand […]

Read full story Comments { 0 }
PHP: calculate percentage of CPU load

PHP: calculate percentage of CPU load

Read first: Function sys_getloadavg in PHP < 5.1.3 This function can calculate percentage of CPU load, work done with LINUX and WINDOWS OS. Usage: Online demo In LINUX OS, we use file /proc/stat to calculate. This file keeps track of a variety of different statistics about the system since it was last restarted. The contents […]

Read full story Comments { 0 }
PHP function: get US state abbreviation from state name

PHP function: get US state abbreviation from state name

In the previous tutorial PHP function: get US state name by abbreviation, we can get US state name by abbreviation. Now, we try to get US state abbreviation from state name. We use function array_flip to flip $state_list: We get the list below: We should use the list with key in lower case: The flipped […]

Read full story Comments { 0 }
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 }