You appear to be a bot. Output may be restricted
Description
Match two associative arrays by key
Usage
$array = OIK_Clone_Compare_List_Table::assoc_array_match( $source_post_meta, $target_post_meta );
Parameters
- $source_post_meta
- ( array ) required –
- $target_post_meta
- ( array ) required –
Returns
array matched arraySource
File name: oik-clone/admin/class-oik-clone-compare-list-table.phpLines:
1 to 49 of 49
function assoc_array_match( $source_post_meta, $target_post_meta ) { ksort( $source_post_meta ); ksort( $target_post_meta ); $matched = array(); $s = current( $source_post_meta ); $skey = key( $source_post_meta ); //echo $skey . $s; $t = current( $target_post_meta ); $tkey = key( $target_post_meta ); $count = 0; while ( $skey !== null && $tkey !== null ) { if ( $skey < $tkey ) { //echo "$skey,$s,"; $matched[$skey] = array( $s, null ); $s = next( $source_post_meta ); $skey = key( $source_post_meta ); } elseif ( $skey > $tkey ) { //echo "$tkey,,$t"; $matched[$tkey] = array( null, $t ); $t = next( $target_post_meta ); $tkey = key( $target_post_meta ); } else { //echo "$skey,$s,$t"; $matched[$skey] = array( $s, $t ); $s = next( $source_post_meta ); $skey = key( $source_post_meta ); $t = next( $target_post_meta ); $tkey = key( $target_post_meta ); } } while ( $skey !== null ) { //echo "more s"; //echo "$skey,$s,"; $matched[$skey] = array( $s, null ); $s = next( $source_post_meta ); $skey = key( $source_post_meta ); //echo PHP_EOL; } while ( $tkey !== null ) { //echo "more t"; //echo "$tkey,,$t"; $matched[$tkey] = array( null, $t ); $t = next( $target_post_meta ); $tkey = key( $target_post_meta ); //echo PHP_EOL; } return( $matched ); }View on GitHub