Author Archive | phptuts

## Google Maps JavaScript API v3: method Polygon.getBounds

In Google Maps JavaScript API v2, Polygon had a getBounds() method, but that doesn’t exist for v3 Polygon. Here’s the solution: Here, we present a simplified method: Image copyright: Google maps

## Google Maps JavaScript API v3: method Polyline.getBounds

In Google Maps JavaScript API v2, Polyline had a getBounds() method, but that doesn’t exist for v3 Polyline. I wrote some methods below: Method 1: Method 2: Method 3 is the shortest method. Image copyright: Google Maps

## 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.

## 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 […]

## 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

## 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:

## 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 […]

## 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 […]

## 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 […]

## 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 […]