Methods summary
public static
array|mixed
#
makeArray ( $value , null $ifNuArray_SplitWith_orNullToWrapAsArray = null )
make value array, e.g 'samson' will become ['samson'] if no param passed in for $ifNuArray_SplitWith_orNullToWrapAsArray , ignore existing array
make value array, e.g 'samson' will become ['samson'] if no param passed in for $ifNuArray_SplitWith_orNullToWrapAsArray , ignore existing array
Parameters
$value
$ifNuArray_SplitWith_orNullToWrapAsArray
Returns
array|mixed
See
Array1::toArray()
public static
array|mixed
#
normalizeIfSingleArray ( array $arrayList )
If Array contains only Single item, return only the item
If Array contains only Single item, return only the item
Parameters
Returns
array|mixed
public static
array|mixed
#
toArray ( $value , null $ifNuArray_SplitWith_orNullToWrapAsArray = null )
make value array, e.g 'samson' will become ['samson'] if no param passed in for $ifNuArray_SplitWith_orNullToWrapAsArray , ignore existing array
make value array, e.g 'samson' will become ['samson'] if no param passed in for $ifNuArray_SplitWith_orNullToWrapAsArray , ignore existing array
Parameters
$value
$ifNuArray_SplitWith_orNullToWrapAsArray
Returns
array|mixed
See
Array1::makeArray()
public static
public static
array
#
orderBy ( array $items , string $keyToSortWith = 'id' , string $orderType = 'asc' )
orderBy(
[
['id' => 2, 'name' => 'Joy'],
['id' => 3, 'name' => 'Khaja'],
['id' => 1, 'name' => 'Raja']
],
'id',
'desc'
); // [['id' => 3, 'name' => 'Khaja'], ['id' => 2, 'name' => 'Joy'], ['id' => 1, 'name' => 'Raja']]
Parameters
$items
$keyToSortWith
$orderType
Returns
array
public static
array
#
groupBy ( $items , $func )
Groups the elements of an array based on the given function.
groupBy(['one', 'two', 'three'], 'strlen'); // [3 => ['one', 'two'], 5 => ['three']]
Groups the elements of an array based on the given function.
groupBy(['one', 'two', 'three'], 'strlen'); // [3 => ['one', 'two'], 5 => ['three']]
Parameters
Returns
array
public static
array
#
flatten ( array $items )
Flattens an array up to the one level depth.
flatten([1, [2], 3, 4]); // [1, 2, 3, 4]
Flattens an array up to the one level depth.
flatten([1, [2], 3, 4]); // [1, 2, 3, 4]
Parameters
Returns
array
public static
array
#
deepFlatten ( $items )
Deep flattens an array.
deepFlatten([1, [2], [[3], 4], 5]); // [1, 2, 3, 4, 5]
Deep flattens an array.
deepFlatten([1, [2], [[3], 4], 5]); // [1, 2, 3, 4, 5]
Parameters
Returns
array
public
boolean
#
ifAll ( $items , $functionToValidateWith )
Returns true if the provided function returns true for all elements of an array, false otherwise.
all([2, 3, 4, 5], function ($item) {
return $item > 1;
}); // true
Returns true if the provided function returns true for all elements of an array, false otherwise.
all([2, 3, 4, 5], function ($item) {
return $item > 1;
}); // true
Parameters
$items
$functionToValidateWith
Returns
boolean
public static
string
#
ifAny ( $items , $functionToValidateWith )
Returns true if the provided function returns true for at least one element of an array, false otherwise.
any([1, 2, 3, 4], function ($item) {
return $item < 2;
}); // true
Returns true if the provided function returns true for at least one element of an array, false otherwise. any([1, 2, 3, 4], function ($item) {
return $item < 2;
}); // true
Parameters
$items
$functionToValidateWith
Returns
string
public static
string
#
hashCode ( $array )
Parameters
Returns
string
public static
public static
public static
#
saveAsJSON ( $array , $toFilePath = null )
Save array to JSON Path
See
Array1::readFromJSON()
public static
boolean|mixed
#
readFromJSON ( null $fromFilePath = null )
Load array from JSON Path
Load array from JSON Path
Parameters
Returns
boolean|mixed
See
Array1::saveAsJSON()
public static
array
#
reUseValueAsKey ( $valueList )
Duplicate array value as key
e.g [hi, hello, thnks] = [hi=hi, hello=hello, thnks=thnks]
Duplicate array value as key e.g [hi, hello, thnks] = [hi=hi, hello=hello, thnks=thnks]
Parameters
Returns
array
public static
array
#
normalizeLinearRequestList ( $linearArray )
This is a type of arrey that occured in form request array of form control
Example to get $_FILE['images'] as separate control, because the control name is array, you will need this
"name" => array(3)
[
0 => string(8) "logo.png"
1 => string(24) "FB_IMG_1477050973313.jpg"
2 => string(24) "FB_IMG_1477050973313.jpg"
]
"type" => array(3)
[
0 => string(9) "image/png"
1 => string(10) "image/jpeg"
2 => string(10) "image/jpeg"
Parameters
Returns
array
public static
array
public static
integer
#
maxOrMin ( $list , string $login = '>' )
Parameters
Returns
integer
public static
string
#
implode ( string $separator , $arrayList , boolean $recursive = true )
Parameters
$separator
$arrayList
$recursive
Returns
string
public static
array
#
fromXMLObject ( $xmlObject )
Extract Array From Mark Up
Extract Array From Mark Up
Parameters
Returns
array
public static
SimpleXMLElement[]
#
fromXML ( $xml_data )
Extract Array From Mark Up
Extract Array From Mark Up
Parameters
Returns
SimpleXMLElement[]
public static
array
#
wrap ( $array , string $append = '' , string $prepend = '' )
Parameters
$array
array
$append
$prepend
Returns
array Surround Array Items with Appended/Prepended Data
public static
string
public static
string
public static
public static
string
#
mergeKeyValue ( array $key_and_value = [] , string $keyValueDelimiter = '=' , string $delimiter = ' ' , string $keyWrap = "%s" , string $valueWrap = "%s" )
Parameters
$key_and_value
$keyValueDelimiter
$delimiter
$keyWrap
$valueWrap
Returns
string
merger KeyValue together
E.G self::mergeKeyValue($key_and_value = ['name'=>'samson', 'email'=>'sams@gmail.com'], $keyValueDelimiter = '=', $delimiter = ' , ', $keyWrap = "%s", $valueWrap = "(%s)")
OUTPUT: name=(samson) , email=(sams@gmail.com)
public static
string
#
toHtmlAttribute ( array $attributes = [] , boolean $allowNumber = false )
Parameters
$attributes
$allowNumber
prevent ['class'=>'col-3', checked, food] = class='col-3' 0="checked" 1="food"
Returns
string class="col-3" checked value="online"
public static
array
#
getArraysWith ( string $startWith = null , null $andEndWith = null , array $arrayToSearch = [] , array $except = [] )
Parameters
$startWith
Start With String
$andEndWith
$arrayToSearch
$except
Returns
array
public static
array
#
splitAndFilterArrayItem ( $delimiter , $string )
Filter and Remove Empty Space from Array
Filter and Remove Empty Space from Array
Parameters
Returns
array
public static
array
#
filterArrayItem ( $array , string $callbackFilterFunction = 'strlen' )
Filter and Remove Empty Space from Array
Filter and Remove Empty Space from Array
Parameters
$array
$callbackFilterFunction
Returns
array
public static
array
#
sanitizeArrayItemValue ( array $array_key_value = [] , array $exceptKeyList = [] , string $callbackSanitizeFunction = 'static::getSanitizeValue' )
Parameters
$array_key_value
$exceptKeyList
$callbackSanitizeFunction
Returns
array Filter array Item With A Function That accept $value Parameter
public static
array
#
initEmptyValueTo ( $arrayList , string $defaultValue = '' , array $excludeKey = [] )
Filter and Remove Empty Space from Array
Filter and Remove Empty Space from Array
Parameters
$arrayList
$defaultValue
$excludeKey
Returns
array
public static
array
#
except ( $arrayList , array $excludeKey = [] )
Remove Un wanted Key From Array
Remove Un wanted Key From Array
Parameters
Returns
array
public static
#
fillRemainingSpace ( & $array , $spaceCountToFill , string $valueToFIll = ' ' )
Fill Data into array, usually useful in Table where you don't want to miss a column, and you trynna balance table rows together.
Fill Data into array, usually useful in Table where you don't want to miss a column, and you trynna balance table rows together.
Parameters
$array
$spaceCountToFill
$valueToFIll
public static
#
trim ( $array = [] , $trimCharSet = '( )"\'' )
public static
#
exists ( $arrayList , $keyToSearch )
public static
public static
public static
array
#
replaceKeyNames ( array $arrayList , array $oldName_equals_to_newName = ['oldName' =>'newName' ] )
Parameters
$arrayList
of Value to replace keyName
$oldName_equals_to_newName
(Replace $arrayList KeyName with keyValue)
Returns
array
public static
array
#
replaceValues ( $arrayList , array $oldValue_equals_to_newValues = ['one' =>'1' ] )
Parameters
$arrayList
of Value to replace keyName
$oldValue_equals_to_newValues
Returns
array
public static
public static
array
#
contain ( array $arrayList = [] , array $needleListToSearch = [] , boolean $recursive = false , string $searchPosition = 'contain' )
Search Array key and Value for a particular list of another array
Parameters
$arrayList
$needleListToSearch
$recursive
$searchPosition
[ could be 'contain' or 'start' or 'end']
Returns
array
See
Array1::startsWith(), @see Array1::endsWith()
public static
#
startsWith ( $arrayList = [] , $needleListToSearch = [] , $recursive = false )
public static
#
endsWith ( $arrayList = [] , $needleListToSearch = [] , $recursive = false )
public static
mixed
#
last ( array $array = [] )
Get Last Array
Parameters
Returns
mixed
public static
array
#
removeLast ( array $array = [] )
Array Pop off last Element
Array Pop off last Element
Parameters
Returns
array
public static
array
#
removeFirst ( array $array = [] )
Array Pop off first Element
Array Pop off first Element
Parameters
Returns
array
public static
array
#
getCommonField ( callable $callback , array $primaryAndCompleteArray , array $otherArray )
Parameters
$callback
$primaryAndCompleteArray
$otherArray
Returns
array
return all common field present in $primaryAndCompleteArray and $otherArrayList1, $otherArrayList2...
FOR LARAVEL REQUEST VALIDATE, USE Request2::getAvailableFields();
public static
string
#
addSlashes ( $arrayList )
Escapse Value with quote
Parameters
Returns
string
public static
array
#
randomElements ( array $array = array ('a' , 'b' , 'c' ) , integer $count = 1 , boolean $allowDuplicates = false )
Parameters
$array
$count
$allowDuplicates
Returns
array