Skip to content
Advertisement

Tag: associative-array

Sorting an associative array with a string in PHP

I’m working on a php issue with an associative array and attempting to sort it. What I have looks something like this: I want to sort it so it looks like this: I’ve thought about exploding along the | and then taking the 0.0.0.111 and comparing it to everything else. What I tried look like this: I realized though that

how to create associative array from NOAA data

I’m trying to convert this to an associative array with json_decode but I’m messing up somewhere. $noaaRaw looks like: How do I convert that to an associative array? Answer file returns an array of lines. You want to use file_get_contents to get a string to decode: It is also possible after that, that you may need to enable allow_url_fopen.

Join two associative arrays in PHP

I have two associative arrays, one is called $events and one is called $wikipedia. I want an efficient way to join “extract” and “thumbnail” from $wikipedia to $events where “name” in $events matches “title” in $wikipedia. Original $events $wikipedia Modified $events with data from $wikipedia What I’ve tried I could achieve this with a nested foreach loop. However this does

Advertisement