Home › Forums › Add-ons › Repeater Field › Combine 2 repeater rows with same values › Reply To: Combine 2 repeater rows with same values
Thanks for that explanation.
On my end, this usort()
call does exactly what it is supposed to:
<?php
$arr = [
0 => [ 'bird_name' => 'C' , ] ,
1 => [ 'bird_name' => 'X' , ] ,
2 => [ 'bird_name' => 'A' , ] ,
3 => [ 'bird_name' => 'F' , ] ,
];
usort(
$arr ,
function( $a , $b ) { return strcmp( $a['bird_name'] , $b['bird_name'] ); }
);
var_dump( $arr );
/*
Prints:
array(4) {
[0]=>
array(1) {
["bird_name"]=>
string(1) "A"
}
[1]=>
array(1) {
["bird_name"]=>
string(1) "C"
}
[2]=>
array(1) {
["bird_name"]=>
string(1) "F"
}
[3]=>
array(1) {
["bird_name"]=>
string(1) "X"
}
}
*/
Are the names perhaps prefixed with information that does not belong there, for example:
and so on? No other possibility comes to my mind.
Please post an example of data that is not sorted correctly.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.