astra_strposa( String $haystack, Array $needles, integer $offset )

Strpos over an array.


Description


Parameters

$haystack

(String) (Required) The string to search in.

$needles

(Array) (Required) Array of needles to be passed to strpos().

$offset

(integer) (Required) If specified, search will start this number of characters counted from the beginning of the string. If the offset is negative, the search will start this number of characters counted from the end of the string.


Return

(bool) True if haystack if part of any of the $needles.


Source

File: inc/extras.php

	function astra_strposa( $haystack, $needles, $offset = 0 ) {

		if ( ! is_array( $needles ) ) {
			$needles = array( $needles );
		}

		foreach ( $needles as $query ) {

			if ( strpos( $haystack, $query, $offset ) !== false ) {
				// stop on first true result.
				return true;
			}
		}

		return false;
	}

Changelog

Changelog
Version Description
1.2.4 Introduced.


User Contributed Notes

You must log in before being able to contribute a note or feedback.