PHP 8.0.30
Preview: ArrayUtils.php Size: 1.49 KB
/home/certprox/template.certproxywizard.com/wp-content/plugins/woocommerce/src/StoreApi/Utilities/ArrayUtils.php

<?php
namespace Automattic\WooCommerce\StoreApi\Utilities;

/**
 * ArrayUtils class used for custom functions to operate on arrays
 */
class ArrayUtils {
	/**
	 * Join a string with a natural language conjunction at the end.
	 *
	 * @param array $array  The array to join together with the natural language conjunction.
	 * @param bool  $enclose_items_with_quotes Whether each item in the array should be enclosed within quotation marks.
	 *
	 * @return string a string containing a list of items and a natural language conjuction.
	 */
	public static function natural_language_join( $array, $enclose_items_with_quotes = false ) {
		if ( true === $enclose_items_with_quotes ) {
			$array = array_map(
				function ( $item ) {
					return '"' . $item . '"';
				},
				$array
			);
		}
		$last = array_pop( $array );
		if ( $array ) {
			return sprintf(
				/* translators: 1: The first n-1 items of a list 2: the last item in the list. */
				__( '%1$s and %2$s', 'woocommerce' ),
				implode( ', ', $array ),
				$last
			);
		}
		return $last;
	}

	/**
	 * Check if a string contains any of the items in an array.
	 *
	 * @param string $needle The string to check.
	 * @param array  $haystack  The array of items to check for.
	 *
	 * @return bool true if the string contains any of the items in the array, false otherwise.
	 */
	public static function string_contains_array( $needle, $haystack ) {
		foreach ( $haystack as $item ) {
			if ( false !== strpos( $needle, $item ) ) {
				return true;
			}
		}
		return false;
	}
}

Directory Contents

Dirs: 0 × Files: 22

Name Size Perms Modified Actions
14.76 KB lrw-r--r-- 2026-06-08 11:45:47
Edit Download
1.49 KB lrw-r--r-- 2026-06-08 11:45:47
Edit Download
48.42 KB lrw-r--r-- 2026-06-08 11:45:47
Edit Download
1.81 KB lrw-r--r-- 2026-06-08 11:45:47
Edit Download
10.82 KB lrw-r--r-- 2026-06-08 11:45:47
Edit Download
1.76 KB lrw-r--r-- 2026-06-08 11:45:47
Edit Download
6.46 KB lrw-r--r-- 2026-07-01 09:07:07
Edit Download
5.45 KB lrw-r--r-- 2026-06-08 11:45:47
Edit Download
5.67 KB lrw-r--r-- 2026-06-08 11:45:47
Edit Download
2.02 KB lrw-r--r-- 2026-06-08 11:45:47
Edit Download
3.29 KB lrw-r--r-- 2026-06-08 11:45:47
Edit Download
32.10 KB lrw-r--r-- 2026-06-08 11:45:47
Edit Download
2.05 KB lrw-r--r-- 2026-06-08 11:45:47
Edit Download
3.65 KB lrw-r--r-- 2026-06-08 11:45:47
Edit Download
3.54 KB lrw-r--r-- 2026-06-08 11:45:47
Edit Download
1.82 KB lrw-r--r-- 2026-06-08 11:45:47
Edit Download
21.61 KB lrw-r--r-- 2026-06-08 11:45:47
Edit Download
9.25 KB lrw-r--r-- 2026-06-08 11:45:47
Edit Download
10.11 KB lrw-r--r-- 2026-06-08 11:45:47
Edit Download
6.14 KB lrw-r--r-- 2026-06-08 11:45:47
Edit Download
794 B lrw-r--r-- 2026-06-08 11:45:47
Edit Download
1.73 KB lrw-r--r-- 2026-06-08 11:45:47
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).