Skip to content
Advertisement

Add keys in associative php array as per reference

I have an array, so I wanted to add keys to each value, for example, if an array contains Facebook URL then the key should be Facebook if an array has a link of Instagram then the key should be Instagram and the list goes on.

Here’s the code

JavaScript
JavaScript

It should become, if the value has a link of twitter then the key should be twitter if Instagram then it should be Instagram

JavaScript

Advertisement

Answer

This maybe? Hope to help

EDITED

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