Supported Versions: PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 8
Applies the callback to the elements of the given arrays
<?php array_map(?callable $callback, array $array, array ...$arrays): array
<?php public function jsonSerialize()
{
return array_map(function ($value) {
if ($this->shallowNesting && $value instanceof Augmentable) {
return $value->toShallowAugmentedArray();
}
if ($value instanceof JsonSerializable) {
return $value->jsonSerialize();
} elseif ($value instanceof Jsonable) {
return json_decode($value->toJson(), true);
} elseif ($value instanceof Arrayable) {
return $value->toArray();
}
return $value;
}, $this->all());
}
}
<?php public function extraRules(): array
{
return array_map([Validator::class, 'explodeRules'], $this->extraRules);
}
public function preProcessValidatable($value)
<?php public function rawurlencode($value)
{
return implode('/', array_map('rawurlencode', explode('/', $value)));
}
<?php public function urlencode($value)
{
return implode('/', array_map('urlencode', explode('/', $value)));
}
<?php protected function toAugmentedArray()
{
Collection::macro('toAugmentedArray', function ($keys = null) {
return array_map(function ($value) use ($keys) {
if ($value instanceof Augmentable) {
return $value->toAugmentedArray($keys);
}
return $value instanceof Arrayable ? $value->toArray() : $value;
}, $this->items);
});
Collection::macro('toAugmentedCollection', function ($keys = null) {
<?php });
Collection::macro('toAugmentedCollection', function ($keys = null) {
return array_map(function ($value) use ($keys) {
if ($value instanceof Augmentable) {
return $value->toAugmentedCollection($keys);
}
return $value instanceof Arrayable ? $value->toArray() : $value;
}, $this->items);
});
}
}
<?php private function standardizeArray($array)
{
$array = array_map('strtolower', $array);
sort($array);
<?php public static function crumb(...$values)
{
return implode(' ‹ ', array_map('__', $values));
}
public static function docsUrl($url)
<?php {
$parts = explode('|', $key);
$key = trim(Arr::get($parts, 0));
$modifiers = array_map('trim', (array) array_slice($parts, 1));
return [$key, $modifiers];
}
<?php $value = $data->antlersValue($this, $context);
if (Str::startsWith($modifier, ':')) {
$parameters = array_map(function ($param) use ($context) {
return $context[$param] ?? null;
}, $parameters);
$modifier = substr($modifier, 1);
}
<?php $arr = $this->user()->toAugmentedArray();
$arr = array_map(function ($item) {
return $item instanceof \Statamic\Fields\Value ? $item->value() : $item;
}, $arr);
$this->assertEquals(array_merge([
'name' => 'John Smith',
<?php {
public function augment($data)
{
return array_map(function ($item) {
return strtoupper($item).'!';
}, $data);
}
};
<?php {
public function augment($data)
{
return array_map(function ($item) {
return is_string($item) ? strtoupper($item).'!' : $item;
}, $data);
}
};