2017 © Pedro Peláez
 

library func-mda

MDA (Multi Dimensional Array) access helpers for PHP

image

openlss/func-mda

MDA (Multi Dimensional Array) access helpers for PHP

  • Sunday, September 8, 2013
  • by nullivex
  • Repository
  • 1 Watchers
  • 3 Stars
  • 23,035 Installations
  • PHP
  • 11 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 13 Versions
  • 4 % Grown

The README.md

openlss/func-mda

MDA (Multi Dimensional Array) access helpers for PHP, (*1)

Usage

$array = array('test'=>array('test2'=>array('test3'=>'value')));

//get a key
$val = mda_get($array,'test.test2.test3'); //returns 'value'

//set a key
mda_set($array,'test.test2.test3','newvalue');

//add a key
mda_add($array,'test.test2.test4','value3');

//get the added key
$val = mda_get($array,'test.test2.test4.0'); //return 'value3'

Reference

Keys (Paths)

MDA keys are used in every function. Sometimes they are referred to as "paths" or "path" * Dotted notation * Notation: mda_get($arr,'index1.index2.index3.index4.0') * Array: $arr['index1']['index2']['index3']['index4'][0] * Argument notation * Notation: mda_get($arr,'index1','index2','index3','index4','0') * Array: $arr['index1']['index2']['index3']['index4'][0] * Mixed Notation * Notation: mda_get($arr,'index1.index2.index3','index4','0') * Array: $arr['index1']['index2']['index3']['index4'][0], (*2)

(mixed) mda_get(&$arr,$path=null)

Returns the key from $arr, (*3)

(mixed) mda_set(&$arr,$path=null)

All of the set functions take the value as the last argument Example, (*4)

mda_set($arr,'index1','index2','index3.index4','value');

(mixed) mda_add(&$arr,$path=null)

Same as set except it adds the value as an anonymous index, (*5)

mda_add($arr,'index1.index2','value');
//is the same as
$arr['index1']['index2'][] = 'value';

(bool) mda_del(&$arr,$path=null)

Delete a path from array, (*6)

(mixed) mda_del_value(&$arr,$path=null)

This will delete all values from a path, (*7)

$arr['index'][0] = 'value';
$arr['index'][1] = 'value';
mda_del_value($arr,'index','value');
$count = count($arr['index']); //returns 0

(bool) mda_exists_value(&$arr,$path=null)

This will check if a value exists in a path, same as mda_del_value(), (*8)

(bool) mda_exists(&$arr,$path)

Checks if a path exists, (*9)

(array) mda_flatten(&$arr,$keyname)

NOTE: this does not take a path it takes a keyname * use mda_get to find the lowest possible path and pass that * to this functions eg: $arr = mda_flatten(mda_get($arr,'path1.path2.path3'),'row_id);, (*10)

(string) implodei($join,$arr=array())

Same prototype as PHPs implode with the enhanced functionality that it will take $join as an array If $join is a string it will pass directly to PHPs implode which is faster Example, (*11)

$array = array(1,2,3,4,5);
$join = array('/','.',',');
$str = implodei($join,$array); //returns 1/2.3,4,5

NOTE: the last member of the array gets repeated, (*12)

(mixed) mda_shift($arr)

NOTE: THIS WILL NOT INCREASE THE ARRAYS POINTER (DOES NOT FUNCTION LIKE ARRAY_SHIFT) Use this to shift anonymous arrays only it does not reference the original array Otherwise its the same as PHPs array_shift(), (*13)

(array) mda_merge($arr,$arr[,$arr...])

Will recursively merge arrays similar to array_merge DOES NOT function like array_merge_recursive which is wrong, (*14)

The Versions

08/09 2013

dev-master

9999999-dev http://openlss.org

MDA (Multi Dimensional Array) access helpers for PHP

  Sources   Download

LGPL-3.0+

The Requires

  • php >=5.3.2

 

The Development Requires

array array helper multi-dimensional array

08/09 2013

dev-0.0.x-dev

dev-0.0.x-dev http://openlss.org

MDA (Multi Dimensional Array) access helpers for PHP

  Sources   Download

LGPL-3.0+

The Requires

  • php >=5.3.2

 

The Development Requires

array array helper multi-dimensional array

08/09 2013

0.0.11

0.0.11.0 http://openlss.org

MDA (Multi Dimensional Array) access helpers for PHP

  Sources   Download

LGPL-3.0+

The Requires

  • php >=5.3.2

 

The Development Requires

array array helper multi-dimensional array

08/09 2013

0.0.10

0.0.10.0 http://openlss.org

MDA (Multi Dimensional Array) access helpers for PHP

  Sources   Download

LGPL-3.0+

The Requires

  • php >=5.3.2

 

The Development Requires

array array helper multi-dimensional array

09/04 2013

0.0.9

0.0.9.0 http://openlss.org

MDA (Multi Dimensional Array) access helpers for PHP

  Sources   Download

LGPL-3.0+

The Requires

  • php >=5.3.2

 

The Development Requires

array array helper multi-dimensional array

07/04 2013

0.0.7

0.0.7.0 http://openlss.org

MDA (Multi Dimensional Array) access helpers for PHP

  Sources   Download

LGPL-3.0+

The Requires

  • php >=5.3.2

 

The Development Requires

array array helper multi-dimensional array

07/04 2013

0.0.8

0.0.8.0 http://openlss.org

MDA (Multi Dimensional Array) access helpers for PHP

  Sources   Download

LGPL-3.0+

The Requires

  • php >=5.3.2

 

The Development Requires

array array helper multi-dimensional array

03/04 2013

0.0.6

0.0.6.0 http://openlss.org

MDA (Multi Dimensional Array) access helpers for PHP

  Sources   Download

LGPL-3.0+

The Requires

  • php >=5.3.2

 

The Development Requires

array array helper multi-dimensional array

26/03 2013

0.0.4

0.0.4.0 http://openlss.org

MDA (Multi Dimensional Array) access helpers for PHP

  Sources   Download

LGPL-3.0+

The Requires

  • php >=5.3.2

 

The Development Requires

array array helper multi-dimensional array

26/03 2013

0.0.5

0.0.5.0 http://openlss.org

MDA (Multi Dimensional Array) access helpers for PHP

  Sources   Download

LGPL-3.0+

The Requires

  • php >=5.3.2

 

The Development Requires

array array helper multi-dimensional array

23/03 2013

0.0.3

0.0.3.0 http://openlss.org

MDA (Multi Dimensional Array) access helpers for PHP

  Sources   Download

LGPL-3.0+

The Requires

 

array array helper multi-dimensional array

23/03 2013

0.0.2

0.0.2.0 http://openlss.org

MDA (Multi Dimensional Array) access helpers for PHP

  Sources   Download

LGPLv2

The Requires

 

array array helper multi-dimensional array

23/03 2013

0.0.1

0.0.1.0 http://openlss.org

MDA (Multi Dimensional Array) access helpers for PHP

  Sources   Download

LGPLv2

The Requires

  • php >=5.3.2

 

array array helper multi-dimensional array