Skip to content
Advertisement

Tag: arrays

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

Array sort by key where keys are clothes sizes (S, M, L, etc.)

I have an array where it’s keys are the sizes and values are either ‘in-stock’ or ‘no-stock’. Example array: I’m trying to sort this by size. Expected output is: I’ve been looking at other similar questions but with no success because those had different array structures. I’m struggling with the uksort function since what I want is to sort the

Advertisement