Stripslashes all values in an array with PHP.

Stripslashes all values in an array with PHP.

April 26, 2010 by aaron
Here is a very simple function to run stripslashes on an array and all of its child arrays. The function below is for PHP 5 and takes a single argument which should consist of an array. It loops through all elements of the array, and if an element is an array, it calls itself on the child array to an infinite depth. Of course this can cause memory problems if your arrays are dynamically created with an excessively large depth, but for most uses, it will function perfectly.
Another look at jQuery Performance: combining elements and IDs

Another look at jQuery Performance: combining elements and IDs

April 23, 2010 by aaron
A question that came up in regards to jQuery Performance was: is it faster to define the type of element before you set the ID. Basically, is jQuery('textarea#content_box') better than jQuery('#content_box')? The thinking is that because the latter is more specific, the parser has to do less work to find the element. But this is wrong and ignores what actually happens in the jQuery code. If you were writing CSS, then yes, it would be faster to define the element type first, but for JavaScript, defining the element type just adds more work for jQuery.
jQuery: Fastest method to find Descendents

jQuery: Fastest method to find Descendents

April 20, 2010 by aaron
In jQuery, there are 5 different selectors that can find an element’s descendants. One of these methods, will grab only first-level children but it is included with the other four to demonstrate the differences. By profiling these 5 selectors, we can get a basic idea of which selector is the fastest, but, as you will see from the graphs, the speed of the different browsers heavily influences the speed of the selector.
Escaping regular expressions in PHP

Escaping regular expressions in PHP

April 10, 2010 by aaron
Escaping dynamic regex strings automatically in PHP is a lot harder than you would think. You can’t just use a string like"\$myregex" because PHP will try to escape the $. You can’t even double slash it like \\$myregex because this doesn’t work in the regex engine. To get both the PHP and the regular expressions to work correctly together, you have to combine quadruple slashes with stripslashes. The Code $escapes = array('.','$','^','[',']','?','+','(',')','*','|','\\'); foreach($escapes as $s){ $r = "\\\\$s"; $myregexbase = str_replace($s, stripslashes($r), $myregexbase); } It’s usage So what sort of time would you need this script you ask?
FireFox Leading the Pack: Gradients on Buttons

FireFox Leading the Pack: Gradients on Buttons

April 3, 2010 by aaron
See those wonderfully beautiful article and comment toggle buttons at the top of every post? (Or in the post image for those reading in a feed reader.) Those are images, but they weren’t created in Photoshop: they are screenshots of buttons designed with Firefox gradients. That’s right, when I was working on them, I wanted buttons done entirely in CSS, but none of the other browsers support both gradients on the button and the gradient borders needed to give the button a feeling of depth without images.
Moving WordPress: Replacing the Old URL in the Database

Moving WordPress: Replacing the Old URL in the Database

April 10, 2010 by aaron
Moving a WordPress website can be quite the hassle, but with the following bit of MySQL it can be a lot easier to switch websites from one host to another. The following is a MySQL search and replace of all fields and text content that could conceivably contain links to your old website. It replaces the old domain name in the options table (those pesky home and siteurls), in the post meta table (for compatibility with random plugins), in the post content (for internal links), in the guid field (for cleanliness), the pinged urls so you don’t ping yourself all over again, and finally the comment content.

Do you have an awesome idea?

Let us know what you want to create.

Start your project