Why PHP Array Functions are so important?

I was building an API for Android. I used Lumen as its blazing fast and based on PHP. And ready to go framework. Everything was easy and fun. But, at one moment I got stuck. I got stuck to return a specific data. As my database was designed by the client and also result was also fixed by the client. The result was odd, in one JSON object the clients so many values with same key or name. But that's not possible.
So, What do I do? without changing the database structure. I got an idea to put a key [ex. 1,  2, 3 so on] with each key name so the name will be unique for the JSON object.

In that time, I faced so many difficulties. As I had to return some data from the database and store them in an array. And the most pathetic part was that, the database return data with some values, from those values I had to use some data one times and some data several times.

It got me mad, then I tried to DISTINCT  the data, but DISTINCT  caused another error of escaping all of the necessary data. At that particular moment, I consult with my BOSS. Then we make it work with array_merge() and array_push() with some nasty and difficult loops. Also learned this call_user_func_array()

After all, the project was a pain but it did teach me a good lesson.

As all the data from database returns as a row or array, so we must be a master of array functions, in some cases, it will definitely help you.

Comments

Popular posts from this blog

Fixing AMPPS MySQL Not Starting and Unable to Change PHP Version

Creating Any Data Types in Dart and Flutter

Mouse Right Button Click, CTRL +U disabling in HTML to protect content from Copying and Viewing source by visitor