ap_in_array_r( mixed $needle, mixed $haystack, boolean $strict = false )

Description #

Find item in in child array.

Parameters #

  • $needle
    mixed (Required) Needle to find.
  • $haystack
    mixed (Required) Haystack.
  • $strict
    boolean (Optional) Strict match. Default value: false

Source #

File: includes/functions.php

function ap_in_array_r( $needle, $haystack, $strict = false ) {
	foreach ( $haystack as $item ) {
		if ( ( $strict ? $item === $needle : $item == $needle ) || ( is_array( $item ) && ap_in_array_r( $needle, $item, $strict ) ) ) { // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual
			return true;
		}
	}
	return false;
}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment