Skip to content
Advertisement

php replace array value

I have following mysql query function:

JavaScript

I get an array of objects with multiple keys:

JavaScript

I am sending the whole array to the js via ajax.

However, I want to change the date format to “ago” and send it to js.

I have the “ago” function, but I am not sure how to target the date value and put it back to its original place (replacement).

Any help would be much appreciate!

Thanks!

Advertisement

Answer

To replace value you can use foreach and change variable on same address

JavaScript

If you dont want to use foreach then you can use array_walk function in place of foreach:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement