Skip to content

Opencart Array Helper provides additional array functionality that you can use in your application.

Notifications You must be signed in to change notification settings

8sun/opencart-array-helper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

opencart-array-helper

Opencart Array Helper provides additional array functionality that you can use in your application.

For more details and usage information on ArrayHelper, see the guide article on array helpers.

This module from Yii2 Framework is adapted by Mefistophell Nill and Zoturn (8sun Empire) especially for OpenCart.

Tested on Opencart 2.0. If you find an error, let us know.

Version: 1.0

See also: Opencart Html Helper

Install

  1. You need copy the files to /system/helper/ directory.

  2. Further add Helpers to /system/startup.php how is shown below:

require_once(DIR_SYSTEM . 'helper/ArrayHelper.php');
require_once(DIR_SYSTEM . 'helper/InvalidParamException.php');

Usage

Just use Helpers into your template files. You may get something following:

$array = [
    ['id' => '123', 'data' => 'abc'],
    ['id' => '345', 'data' => 'def'],
];
$result = ArrayHelper::getColumn($array, 'id');
// the result is: ['123', '345']

Here is the list of available features

MethodDescription
filter() Filters array according to rules specified.
getColumn() Returns the values of a specified column in an array.
getValue() Retrieves the value of an array element or object property with the given key or property name.
htmlDecode() Decodes HTML entities into the corresponding characters in an array of strings.
htmlEncode() Encodes special characters in an array of strings into HTML entities.
index() Indexes and/or groups the array according to a specified key.
isAssociative() Returns a value indicating whether the given array is an associative array.
isIn() Check whether an array or Traversable contains an element.
isIndexed() Returns a value indicating whether the given array is an indexed array.
isSubset() Checks whether an array or Traversable is a subset of another array or Traversable.
isTraversable() Checks whether a variable is an array or Traversable.
keyExists() Checks if the given array contains the specified key.
map() Builds a map (key-value pairs) from a multidimensional array or an array of objects.
merge() Merges two or more arrays into one recursively.
multisort() Sorts an array of objects or arrays (with the same structure) by one or several keys.
remove() Removes an item from an array and returns the value. If the key does not exist in the array, the default value will be returned instead.
removeValue() Removes items with matching values from the array and returns the removed items.
toArray() Converts an object or an array of objects into an array.

About

Opencart Array Helper provides additional array functionality that you can use in your application.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages