Search a Multi-dimensional Array for a Key

It’s not every day that one needs to search a multi-dimensional array for a key, and return the associated value, but a simple recursive function allows such an action. In a project I was working on recently, I needed to check the status of a record, but the status array was segmented into three main categories.

So I wrote a quick recursive function to handle the task. Please note, the function will only work if all keys are different. No two keys in the multi-dimensional array can be the same! Yes, I said it twice, but to emphasize that it matters.

Continue reading

Posted in PHP

PHP Framework Side-by-Side with WordPress

I was working on a website this week where I wanted to use WordPress so the client could benefit from its CMS and blogging capabilites, but also wanted to use a PHP framework to handle some custom programming. Compared to WordPress, almost any PHP framework is going to be easier to do custom programming with. But what about routing? How will the website know what to route to the framework, and what to route to WordPress?

Continue reading

Searching WP Comments Before Enqueue

WordPress makes it relatively easy to search through post content before it’s too late to use its wp_enqueue_script or wp_enqueue_style functions. Comments on the other hand don’t have an action hook that is called early enough.

This blog uses Alex Gorbatchev’s Syntax Highlighter for a styled display of code. It’s really easy to implement, but required creating a plugin to check posts and comments for highlighted code. I wanted to load the associated JavaScript and CSS for blog singles and pages when needed, but not load them when there is no code to highlight.

Continue reading

The Mysterious MLS API

It’s amazing how hard it is to find information regarding access to the MLS. I know three real estate brokers, but they aren’t much help; they’re too busy selling houses, and it’s really not something they should be expected to know. I’ve tried asking some web design agencies, but they haven’t been helpful, and many of them host the websites they create, so it’s impossible to browse server-side code and figure anything out. I’ll admit, I probably just didn’t know what to search for, or who to ask the right questions to.

Continue reading