Skip to content

Commit f33c321

Browse files
committed
Add is_assoc util function
Signed-off-by: Kirtan Gajjar <[email protected]>
1 parent 483b095 commit f33c321

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

php/utils.php

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44

55
namespace EE\Utils;
66

7-
use \Composer\Semver\Comparator;
8-
use \Composer\Semver\Semver;
9-
use \EE;
10-
use \EE\Dispatcher;
11-
use \EE\Iterators\Transform;
7+
use Composer\Semver\Comparator;
8+
use Composer\Semver\Semver;
9+
use EE;
10+
use EE\Iterators\Transform;
1211

1312
const PHAR_STREAM_PREFIX = 'phar://';
1413

@@ -423,6 +422,20 @@ function make_progress_bar( $message, $count, $interval = 100 ) {
423422
return new \cli\progress\Bar( $message, $count, $interval );
424423
}
425424

425+
/**
426+
* Checks if an array is associative array
427+
* @param array $arr array to check
428+
*
429+
* @return bool
430+
*/
431+
function is_assoc( array $arr ) {
432+
if ( array() === $arr ) {
433+
return false;
434+
}
435+
436+
return array_keys( $arr ) !== range( 0, count( $arr ) - 1 );
437+
}
438+
426439
function parse_url( $url ) {
427440
$url_parts = \parse_url( $url );
428441

0 commit comments

Comments
 (0)