Commit eb3557b5 authored by Sylvain's avatar Sylvain

Ajout d'un helper array - test de tableau indexé

parent 5aa9938d
......@@ -43,6 +43,9 @@ Laravel 5.8 uses autoload files, so doesn't require you to manually add the Serv
- [str_indent](#str_indent)
- [str_args_to_array](#str_args_to_array)
**_Array_**
- [is_indexed_array](#is_indexed_array)
**_Time_**
- [sum_times](#sum_times)
- [gte_time](#gte_time)
......@@ -269,7 +272,6 @@ $getters = ['content.key', 'content.value'];
$price = mixte_get_multi($source, $getters, $default = null);
// ["my-key", "my-value"]
```
#### `public_folder_to_urls()`
......@@ -278,9 +280,19 @@ La fonction `public_folder_to_urls()` récupère une colelction d'url de fichier
```php
$urls = public_folder_to_urls("upload/folder/");
// Collection(['http://domain.tld/upload/folder/images1.png', 'http://domain.tld/upload/folder/images2.png'])
```
is_indexed_array
#### `is_indexed_array()`
La fonction `is_indexed_array()` teste un tableau pour savoir s'il est de type indexé ou associatif
```php
$urls = is_indexed_array(['foo', 'bar']);
// true
$urls = is_indexed_array(['foo' => 'bar', 'boo' => 'tite']);
// false
```
## Security
......
......@@ -18,6 +18,7 @@
"files": [
"src/convert.php",
"src/divers.php",
"src/array.php",
"src/image.php",
"src/html.php",
"src/list.php",
......
<?php
if ( !function_exists('is_indexed_array')) {
/**
* Test si un tableau est de type indexé
*
* @param array Le tableau à tester
* @return bool
*/
function is_indexed_array(array $array): bool
{
return array_keys($array) === range(0, count($array) - 1) && count($array) == 1;
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment