Tribe__Utils__Array::stringify_keys( array $input, string|null $prefix = null )

Stringifies the numeric keys of an array.


Parameters

$input

(<span class="arrayarray<int|">string,mixed>) (Required) The input array whose keys should be stringified.

$prefix

(string|null) (Optional) The prefix that should be use to stringify the keys, if not provided then it will be generated.

Default value: null


Top ↑

Return

(array<string,mixed>) The input array with each numeric key stringified.


Top ↑

Source

File: src/Tribe/Utils/Array.php

		public static function stringify_keys( array $input, $prefix = null ) {
			$prefix  = null === $prefix ? uniqid( 'sk_', true ) : $prefix;
			$visitor = static function ( $key, $value ) use ( $prefix ) {
				$string_key = is_numeric( $key ) ? $prefix . $key : $key;

				return [ $string_key, $value ];
			};

			return static::array_visit_recursive( $input, $visitor );
		}

Top ↑

Changelog

Changelog
Version Description
4.12.14 Introduced.