[ Index ]
 

Code source de CakePHP 1.1.13.4450

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/cake/libs/ -> neat_array.php (sommaire)

Library of array functions for Cake. Internal use only.

Copyright: Copyright 2005-2007, Cake Software Foundation, Inc.
License: http://www.opensource.org/licenses/mit-license.php The MIT License
Version: $Revision: 4409 $
Poids: 318 lignes (8 kb)
Inclus ou requis:0 fois
Référencé: 0 fois
Nécessite: 0 fichiers

Définit 1 class

NeatArray:: (15 méthodes):
  NeatArray()
  findIn()
  cleanup()
  add()
  plus()
  totals()
  filter()
  walk()
  sprintf()
  extract()
  unique()
  makeUnique()
  joinWith()
  threaded()
  multi_search()


Classe: NeatArray  - X-Ref

Class used for internal manipulation of multi-dimensional arrays (arrays of arrays).

Long description for class

NeatArray($value = array()   X-Ref
Constructor. Defaults to an empty array.

param: array $value

findIn($fieldName, $value)   X-Ref
Finds and returns records with $fieldName equal to $value from this NeatArray.

param: string $fieldName
param: string $value
return: mixed

cleanup()   X-Ref
Checks if $this->value is an array, and removes all empty elements.


add($value)   X-Ref
Adds elements from given array to itself.

param: string $value
return: bool

plus($value)   X-Ref
Returns itself merged with given array.

param: array $value Array to add to NeatArray.
return: array

totals($sortedBy = 1, $reverse = true)   X-Ref
Counts repeating strings and returns an array of totals.

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

filter($with)   X-Ref
Performs an array_filter() on the contents of this NeatArray.

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

walk($with)   X-Ref
Passes each of its values through a specified function or method.
Think of PHP's {@link http://php.net/array_walk array_walk()}.

param: string $with Name of callback function
return: array Returns value of NeatArray::value

sprintf($template)   X-Ref
Apply $template to all elements of this NeatArray, and return the array itself.

param: string $template {@link http://php.net/sprintf sprintf()}-compatible string to be applied to all values of this NeatArray.
return: array

extract($name)   X-Ref
Extracts a value from all array items.

return: array

unique()   X-Ref
Returns a list of unique elements.

return: array

makeUnique()   X-Ref
Removes duplicate elements from the value and returns it.

return: array

joinWith($his, $onMine, $onHis = null)   X-Ref
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')
);

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

threaded($root = null, $idKey = 'id', $parentIdKey = 'parent_id', $childrenKey = 'children')   X-Ref
Enter description here...

param: string $root
param: string $idKey
param: string $parentIdKey
param: string $childrenKey
return: array

multi_search($search_value, $the_array = null)   X-Ref
Array multi search

param: string $search_value
param: array $the_array
return: array



Généré le : Sun Feb 25 19:27:47 2007 par Balluche grâce à PHPXref 0.7