How to zero fill a number with PHP

By Josh Sherman
1 min read
development
php

Zero filling (or zero padding) is when you pad a value on the left side to a specific length. This is something you will commonly see in database schemas for integer columns. But what if we’re not working with data that’s already zero filled by a database? All we have […]

How to get keys from an associative array in PHP

By Josh Sherman
1 min read
development
php

One of PHP’s most powerful features are arrays and the multitude of functions available to interact with and manipulate them. Arrays can be indexed by integers as well as string, known as an associative array. Instead of looping through the array with foreach and assigning the key to another array, […]

Dynamic page titles with GitHub Pages

By Josh Sherman
2 min read
development
github
github pages
jekyll

Ran into a bit of an issue today when deploying some changes to my blog. The home page, which was working just fine locally, was being treated as if it were a blog post page. What keyed me off to this was the title of the page which was “joshtronic […]

Passing variables to anonymous PHP functions

By Josh Sherman
1 min read
development
php

The other day I ran into a situation (first time, it seems) where I needed to access a variable inside of an anonymous function inside of preg_replace_callback(). My first thought, even though it went against my better judgement was to simply define the variables as global inside of the function. […]

Opt-out responsive design using LESS

By Josh Sherman
1 min read
development
design
css
less

I liked Chris Coyier’s post Opt-Out Responsive Design? but really didn’t like the idea of having to qualify all of my selectors with a parent class to indicate that we should be using the responsive version of the site. I do favor serving the user a single stylesheet instead of […]