Support

Account

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:

    • “B” is in fact “other_pigeons_and_doves B”
    • “A” is in fact “pigeons_and_doves A”
    • “X” is in fact “pigeons_and_doves X”

    and so on? No other possibility comes to my mind.

    Please post an example of data that is not sorted correctly.