PHP 클래스 a, kirby

파일 보기 프로젝트 열기: bastianallgeier/kirby 1 사용 예제들

공개 메소드들

메소드 설명
contains ( array $array, string $search ) : boolean Checks if an array contains a certain string
extract ( array $array, string $key ) : array Extracts a single column from an array
fill ( array $array, integer $limit, mixed $fill = 'placeholder' ) : array Fills an array up with additional elements to certain amount.
first ( array $array ) : mixed Returns the first element of an array
get ( array $array, mixed $key, mixed $default = null ) : mixed Gets an element of an array by key
getall ( array $array, $keys ) : array Gets all elements for an array of key
inject ( array $array, integer $position, mixed $element = 'placeholder' ) : array Injects an element into an array
json ( array $array ) : string Converts an array to a JSON string It's basically a shortcut for json_encode()
last ( array $array ) : mixed Returns the last element of an array
missing ( array $array, array $required = [] ) : array Checks for missing elements in an array
remove ( array $array, mixed $search, boolean $key = true ) : array Removes an element from an array
search ( array $array, string $search ) : array Search for elements in an array by regular expression
show ( array $array, boolean $echo = true ) : mixed Shows an entire array or object in a human readable way This is perfect for debugging
shuffle ( array $array ) : array Shuffles an array and keeps the keys
sort ( array $array, string $field, string $direction = 'desc', const $method = SORT_REGULAR ) : array Sorts a multi-dimensional array by a certain column
xml ( array $array, string $tag = 'root', boolean $head = true, string $charset = 'utf-8', $tab = ' ', integer $level ) : string Converts an array to a XML string

메소드 상세

contains() 정적인 공개 메소드

Checks if an array contains a certain string
static public contains ( array $array, string $search ) : boolean
$array array The source array
$search string The string to search for
리턴 boolean true: the array contains the string, false: it doesn't

extract() 정적인 공개 메소드

Extracts a single column from an array
static public extract ( array $array, string $key ) : array
$array array The source array
$key string The key name of the column to extract
리턴 array The result array with all values from that column.

fill() 정적인 공개 메소드

Fills an array up with additional elements to certain amount.
static public fill ( array $array, integer $limit, mixed $fill = 'placeholder' ) : array
$array array The source array
$limit integer The number of elements the array should contain after filling it up.
$fill mixed The element, which should be used to fill the array
리턴 array The filled-up result array

first() 정적인 공개 메소드

I always have to lookup the names of that function so I decided to make this shortcut which is easier to remember.
static public first ( array $array ) : mixed
$array array The source array
리턴 mixed The first element

get() 정적인 공개 메소드

Gets an element of an array by key
static public get ( array $array, mixed $key, mixed $default = null ) : mixed
$array array The source array
$key mixed The key to look for
$default mixed Optional default value, which should be returned if no element has been found
리턴 mixed

getall() 정적인 공개 메소드

Gets all elements for an array of key
static public getall ( array $array, $keys ) : array
$array array The source array
리턴 array An array of keys and matching values

inject() 정적인 공개 메소드

Injects an element into an array
static public inject ( array $array, integer $position, mixed $element = 'placeholder' ) : array
$array array The source array
$position integer The position, where to inject the element
$element mixed The element, which should be injected
리턴 array The result array including the new element

json() 정적인 공개 메소드

Converts an array to a JSON string It's basically a shortcut for json_encode()
static public json ( array $array ) : string
$array array The source array
리턴 string The JSON string

last() 정적인 공개 메소드

I always have to lookup the names of that function so I decided to make this shortcut which is easier to remember.
static public last ( array $array ) : mixed
$array array The source array
리턴 mixed The last element

missing() 정적인 공개 메소드

This is very handy to check for missing user values in a request for example.
static public missing ( array $array, array $required = [] ) : array
$array array The source array
$required array An array of required keys
리턴 array An array of missing fields. If this is empty, nothing is missing.

remove() 정적인 공개 메소드

Removes an element from an array
static public remove ( array $array, mixed $search, boolean $key = true ) : array
$array array The source array
$search mixed The value or key to look for
$key boolean Pass true to search for an key, pass false to search for an value.
리턴 array The result array without the removed element

show() 정적인 공개 메소드

Shows an entire array or object in a human readable way This is perfect for debugging
static public show ( array $array, boolean $echo = true ) : mixed
$array array The source array
$echo boolean By default the result will be echoed instantly. You can switch that off here.
리턴 mixed If echo is false, this will return the generated array output.

shuffle() 정적인 공개 메소드

Shuffles an array and keeps the keys
static public shuffle ( array $array ) : array
$array array The source array
리턴 array The shuffled result array

sort() 정적인 공개 메소드

Sorts a multi-dimensional array by a certain column
static public sort ( array $array, string $field, string $direction = 'desc', const $method = SORT_REGULAR ) : array
$array array The source array
$field string The name of the column
$direction string desc (descending) or asc (ascending)
$method const A PHP sort method flag.
리턴 array The sorted array

xml() 정적인 공개 메소드

Converts an array to a XML string
static public xml ( array $array, string $tag = 'root', boolean $head = true, string $charset = 'utf-8', $tab = ' ', integer $level ) : string
$array array The source array
$tag string The name of the root element
$head boolean Include the xml declaration head or not
$charset string The charset, which should be used for the header
$level integer The indendation level
리턴 string The XML string