简体   繁体   中英

Double array in foreach loop

I am modifying a php function. there is foreach loop which is annoying for me. below is the source code

$array_a = array(
 //value here.
);
$array_b = array(
 //value here.
)
foreach ( $array_a + $array_b as $key => $query ) {
 unset( $meta_key[ $key ] ); //or whatever
}

Question

$array_a + $array_b

why they are using two arrays & i think there is an increment operator between them. i want to know the logic and reason of doing that?

The + operator appends elements of remaining keys from the right handed array to the left handed, whereas duplicated keys are NOT overwritten. With the foreach loop basically he is going through the array keys and values,

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM