Ness PHP Array Helper
You can include this library to your code file by typing the below code;
use Ness\Helpers\Arrays
Result:
- Contents
Required Namespace
- Ness
- Helpers
- Arrays
- Helpers
You can include this library to your code file by typing the below code;
use Ness\Helpers\Arrays
About Arrays Helper #top
This is a helper class for arrays. It's adds various features to arrays.
Methods #top
getElement
Arrays::getElement($array_name, $element)
Select one or more element from an array. | ||
Return | Array | String | Integer | ... | |
Parameters | $array_name Array; selected array to operate with $element String|Array; element(s) to select from array |
setEmpty
Arrays::setEmpty($array_name, $element)
Sets element(s) of array to empty. | ||
Return | void | |
Parameters | $array_name Array; selected array to operate with $element String|Array; element(s) to set empty |
setNull
Arrays::setNull($array_name, $element)
Sets element(s) of array to Null. | ||
Return | void | |
Parameters | $array_name Array; selected array to operate with $element String|Array; element(s) to set null |
Reverse
Arrays::Reverse($array_name, $type)
Reverse an array horizontally or vertically. | ||
Return | Array | |
Parameters | $array_name Array; selected array to operate with $type String; h for horizontal and v for vertical |
Examples #top
/**
* Test variable
*/
echo "
Default:
";
$user_data = array("username"=>"sinansalih0",
"lang"=>"tr",
"login_time"=>"12:33:25 - 06/06/2019");
var_dump($user_data);
echo "
Reverse Vertical:
";
var_dump(Ness\Helpers\Arrays::Reverse($user_data, 'v'));
echo "
Reverse Horizontal:
";
var_dump(Ness\Helpers\Arrays::Reverse($user_data, 'h'));
Result:
Default: array(3) { ["username"]=> string(11) "sinansalih0" ["lang"]=> string(2) "tr" ["login_time"]=> string(21) "12:33:25 - 06/06/2019" } Reverse Vertical: array(3) { ["login_time"]=> string(21) "12:33:25 - 06/06/2019" ["lang"]=> string(2) "tr" ["username"]=> string(11) "sinansalih0" } Reverse Horizontal: array(3) { ["12:33:25 - 06/06/2019"]=> string(10) "login_time" ["tr"]=> string(4) "lang" ["sinansalih0"]=> string(8) "username" }