NeatArray Class Reference

List of all members.


Public Member Functions

 add ($value)
 cleanup ()
 extract ($name)
 filter ($with)
 findIn ($fieldName, $value)
 joinWith ($his, $onMine, $onHis=null)
 makeUnique ()
 multi_search ($search_value, $the_array=null)
 NeatArray ($value=array())
 plus ($value)
 sprintf ($template)
 threaded ($root=null, $idKey= 'id', $parentIdKey= 'parent_id', $childrenKey= 'children')
 totals ($sortedBy=1, $reverse=true)
 unique ()
 walk ($with)

Public Attributes

 $value

Detailed Description

Definition at line 37 of file neat_array.php.


Member Function Documentation

NeatArray::add ( value  ) 

Adds elements from given array to itself.

Parameters:
string $value
Returns:
bool public NeatArray::value

Definition at line 105 of file neat_array.php.

References $value, and plus().

NeatArray::cleanup (  ) 

Checks if $this->value is an array, and removes all empty elements.

public NeatArray::value

Definition at line 86 of file neat_array.php.

References $v.

NeatArray::extract ( name  ) 

Extracts a value from all array items.

Returns:
array public NeatArray::value

Definition at line 185 of file neat_array.php.

NeatArray::filter ( with  ) 

Performs an array_filter() on the contents of this NeatArray.

Parameters:
string $with Name of callback function to perform on each element of this NeatArray.
Returns:
array

Definition at line 149 of file neat_array.php.

NeatArray::findIn ( fieldName,
value 
)

Finds and returns records with $fieldName equal to $value from this NeatArray.

Parameters:
string $fieldName
string $value
Returns:
mixed public NeatArray::value

Definition at line 64 of file neat_array.php.

References $value.

Referenced by joinWith().

NeatArray::joinWith ( his,
onMine,
onHis = null 
)

Joins an array with myself using a key (like a join between database tables).

Example:

$alice = array('id'=>'1', 'name'=>'Alice'); $bob = array('id'=>'2', 'name'=>'Bob');

$users = new NeatArray(array($alice, $bob));

$born = array ( array('user_id'=>'1', 'born'=>'1980'), array('user_id'=>'2', 'born'=>'1976') );

$users->joinWith($born, 'id', 'user_id');

Result:

$users->value == array ( array('id'=>'1', 'name'=>'Alice', 'born'=>'1980'), array('id'=>'2', 'name'=>'Bob', 'born'=>'1976') );

Parameters:
array $his The array to join with myself.
string $onMine Key to use on myself.
string $onHis Key to use on him.
Returns:
array

Definition at line 241 of file neat_array.php.

References findIn(), and NeatArray().

NeatArray::makeUnique (  ) 

Removes duplicate elements from the value and returns it.

Returns:
array

Definition at line 207 of file neat_array.php.

NeatArray::multi_search ( search_value,
the_array = null 
)

Array multi search

Parameters:
string $search_value
array $the_array
Returns:
array http://php.net/array_search#47116

Definition at line 290 of file neat_array.php.

References $value.

NeatArray::NeatArray ( value = array()  ) 

Constructor. Defaults to an empty array.

Parameters:
array $value public NeatArray::value

Definition at line 52 of file neat_array.php.

References $value.

Referenced by joinWith().

NeatArray::plus ( value  ) 

Returns itself merged with given array.

Parameters:
array $value Array to add to NeatArray.
Returns:
array public NeatArray::value

Definition at line 116 of file neat_array.php.

References $value.

Referenced by add().

NeatArray::sprintf ( template  ) 

Apply $template to all elements of this NeatArray, and return the array itself.

Parameters:
string $template sprintf()-compatible string to be applied to all values of this NeatArray.
Returns:
array

Definition at line 171 of file neat_array.php.

NeatArray::threaded ( root = null,
idKey = 'id',
parentIdKey = 'parent_id',
childrenKey = 'children' 
)

Enter description here...

Todo:
Explain this function. almost looks like it creates a tree
Parameters:
string $root
string $idKey
string $parentIdKey
string $childrenKey
Returns:
array

Definition at line 268 of file neat_array.php.

References $root.

NeatArray::totals ( sortedBy = 1,
reverse = true 
)

Counts repeating strings and returns an array of totals.

Parameters:
int $sortedBy A value of 1 sorts by values, a value of 2 sorts by keys. Defaults to null (no sorting).
Returns:
array public NeatArray::value

Definition at line 128 of file neat_array.php.

NeatArray::unique (  ) 

Returns a list of unique elements.

Returns:
array

Definition at line 198 of file neat_array.php.

NeatArray::walk ( with  ) 

Passes each of its values through a specified function or method. Think of PHP's array_walk().

Parameters:
string $with Name of callback function
Returns:
array Returns value of NeatArray::value public NeatArray::value

Definition at line 161 of file neat_array.php.


Member Data Documentation

NeatArray::$value

Definition at line 44 of file neat_array.php.

Referenced by add(), findIn(), multi_search(), NeatArray(), and plus().


The documentation for this class was generated from the following file: