仅用于PHP辅助类的包。

v0.2.5 2022-07-29 16:53 UTC

This package is auto-updated.

Last update: 2024-09-29 06:20:07 UTC


README

Scrutinizer Code Quality Code Coverage Total Downloads License

用于在多个项目中共享有用内容的工具包。

安装

composer require braunstetter/helper

数组

attachClass

此方法在需要向现有类字符串添加类时非常有用。

Braunstetter\Helper\Arr::attachClass([ 'class' => 'mx-4 my-2' ], 'container')

# output:
# ['class' => 'mx-4 my-2 container']

attach

有时只是想向现有字符串添加一些新属性。

Braunstetter\Helper\Arr::attach(
    [ 'data-controller' => 'example'],
    [ 'data-controller' => 'another-example']
)

# output: 
# ['data-controller' => 'example another-example']

firstValue

返回给定数组的第一个值。如果数组为空,则返回null。

Braunstetter\Helper\Arr::firstValue([
    3 => 'first',
    2 => 'second',
    0 => 'third'
])

# output:
# first