Laravel get most recent array item for each day in array

I’m trying to figure out the best way (whether I do this using the query builder or raw PHP) to get the most recent array item based on it’s created_at timestamp for a given day, in an array …

PHP: Combine and sort two multidimensional arrays with same value

I have two multidimensional arrays in PHP, the first one being [0] => [ ‘id’ => 123, ‘name’ => ‘John’ ], [1] => [ ‘id’ => 456, ‘name’ => ‘Anna’ ], [2] => [ ‘id’ => 789, ‘name’…

Sort by custom meta value doesn’t work in WooCommerce products sort by

I’m trying to add a sorting option for woocommerce products’s list. The goal is to sort products by a meta value with meta key called _rating. For now I generate this meta value with a function …

Sort Multiple Array to Numeric order (1,2,…,9,10,11) and Alphabetical order in PHP

How can I sort multidimensional array in numeric order first and then in alphabetical order in PHP. I have one array : { “id”: “220”, “pin_list”: [ { …

How to use usort to sort MongoDB query result

Trying to sort array present in object but getting error usort() expects parameter 1 to be array I have not found any useful solution for this error on anywhere, How can I sort my array[detail] by …

PHP sorting multidimensional array issue

this is how my array look likes: array(2) { ‘yamaha’ => array(2) { ‘r1’ => array(3) { [0] => string(4) “2000” [1] => string(4) “2001”…

Mongo distinct query with sort not working

I’m running a query in mongo using php like this: $column =’address.roadname’; (new MongoDBClient())->db->mycollection->distinct($column,[],[‘$sort’=> [$column => 1]]); The query …

How to combine multiple sorting functions

It works like a charm in SQL: SELECT * FROM person ORDER BY age DESC, name ASC But what if we have such data in PHP array. How can we do the same? For example, if I have $a = [ [‘name’ => ‘…

How do I move an array element with a known key weight of an array in PHP?

Having a brain freeze over a fairly trivial problem. If I start with an array like this: $my_array = array( 1 => [ “id” => 1, “weight” => 0 ], 2 => [ …

How to use multiple sort_flags in PHP array sorting (Using SORT_LOCALE_STRING , SORT_NATURAL)?

How to use multiple sort_flags in PHP array sorting (Using SORT_LOCALE_STRING , SORT_NATURAL)? I want to using SORT_LOCALE_STRING for UTF8 languages + SORT_NATURAL Numbers. I want to Sort the …