PHP MySQL Result json_encode Includes Value And Its Column Index As Key

While this is not really an error, extra data that is not used should not be included in any output as it will only add to the extra bytes.

When you look at your JSON output, you realized the column names and values also have extra index column numbers and the associated values included.

To remove this, simply add an option in the PDO when you instantiate a database connection in PHP like this:

That should fix the problem. When you use json_encode(), there will be no more duplicate values with the corresponding column index number as key.

Don’t Upgrade To WordPress 3.8!

wordpress_hexThis was a mess. I did not expect WordPress 3.8 to slow down my blog site. As in literally! The admin console takes too long to load and so do my blog posts.

I tried to look in the web for a solution but it seems people are blaming the hosting provider or possible WordPress plugins. Unbelievable!

Everything was in good condition until I pressed that update button. And it is quite a hassle downgrading so it totally sucks. If you have not upgraded to WordPress 3.8, DON’T!!!

Sure, the visuals look appealing but who surfs the web in their phones in the first place? Just go download the WordPress app.

If you upgrade to WordPress 3.8, it will be hell for you. Load time is slow and you will see connection timed out messages quite often especially while you compose a new post.

Now my monetization chances are getting slimmer because if the advertiser sees your site as loading at a snail pace, they will ignore your website.

So if you are still with version 3.7, stick with it! It won’t hurt you.

How To Check If Array Element Exists In Another Array In PHP

This is the best 1 liner answer I found in the Internet to check if an array’s item or value or however you may call it exists in another array.

Using the function array_intersect(), you can achieve this. User lorenzo-s from Stack Overflow gave this 1 liner code that did the trick.

Do note that array_intersect() is case sensitive.

Related Posts Plugin for WordPress, Blogger...