Google maps api key for localhost

July 30, 2014

For google maps api v3, the key must be empty for it to work in localhost. Older version key check is skipped for http://localhost/. You could use the key that you intend to use on your live domain, or anything else. If you use a port number with localhost, then you can obtain a key […]

PHP check a string is an email address format

July 29, 2014

With PHP v5.2.0 or greater, you may use regular expressions.

jQuery add attribute to html element and remove

July 25, 2014

You can add attributes using attr like below: To remove: However, for DOM properties like checked, disabled and readonly, the proper way to do this (as of JQuery 1.6) is to use prop. To remove:

jQuery checkbox checked state changed event

July 25, 2014

Bind to the change event instead of click. However, you will probably still need to check whether or not the checkbox is checked: Example below shows and hide a div when checkbox checked or unchecked

PHP replace spaces in urls image name

July 21, 2014

Looking to replace all instances of spaces in urls with %20? No need for a regex. Use rawurlencode() instead urlencode() for this purpose. Example: urlencode($img) will result It will not change to %20. But with rawurlencode($img), it produce Another way of doing it is using str_replace

Jquery read element attribute id with square brackets [ ]

July 16, 2014

To use any of the meta-characters ( such as !”#$%&’()*+,./:;?@[\]^`{|}~ ) as a literal part of a name, it must be escaped with with two backslashes: \\. For example, an element with id=””, can use the selector $(“#foo\\.bar”). Example: Reference: Special Characters In Selectors

PHP sort multidimensional Array by specific key value

July 14, 2014

Try usort for multidimensional array sorting by specific key value inside each sub array. Example: The best way is: reference:

Bootstrap responsive Youtube Youku video embed

July 14, 2014

The bootstrap is not a magic tool, its just a layout engine. Just use the grid provided by bootstrap and remove strict width on the iframe. Use the bootstrap class guides replace the width. For better view of the video, may keep the height. Youtube: Youku example:

FUELPHP Form Checkbox checked

July 1, 2014

FuelPHP checkbox is not a nightmare if understand it’s parameters correctly. The syntax is checkbox($field, $value = null, $checked = null, $attributes = array()) To built form checkbox, simply do like below: Will output a checked checkbox: To uncheck the checkbox, changed the ‘checked’ value to empty ” or null