core
[ class tree: core ] [ index: core ] [ all elements ]

Class: Arrays

Source Location: /core/Arrays.class.php

Class Overview

ABSTObject
   |
   --Arrays

Static methods to manipulate arrays.


Author(s):

Version:

  • 0.2.97

Copyright:

  • Copyright (c) 2003 Daniel Plücken <daniel@debakel.net>

    This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License.

    This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

Methods


Child classes:

Inherited Methods

Class: ABSTObject

ABSTObject::printComplexData()
Prints out the more complex data by the given array.
ABSTObject::printPrimitiveData()
Prints out the primitive data by the given arrays.
ABSTObject::printStructure()
Prints out the Structure of this Object.
ABSTObject::same()
Checks whether the passed object reference points to this object.
ABSTObject::sameReferences()
Compares two references whether they points to the same object

Class Details

[line 63]
Static methods to manipulate arrays.



Tags:

author:  Daniel Plücken <daniel@debakel.net>
version:  0.2.97
copyright:  

Copyright (c) 2003 Daniel Plücken <daniel@debakel.net>

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

license:  GNU Lesser General Public License


[ Top ]


Class Methods


static method assoc2index [line 147]

static array assoc2index( &$array, array $array)

Returns the given array as an index based array.



Tags:

version:  1.0
since:  0.2.1
access:  public


Parameters:

array   $array   The array that should be converted.
   &$array  

[ Top ]

static method complementArrays [line 512]

static array complementArrays( &$array1, &$array2, array $array1, array $array2)

Merges two arrays to one. All records that occuring in both arrays will be remove.



Tags:

version:  1.1
since:  0.1.8
access:  public


Parameters:

array   $array1  
array   $array2  
   &$array1  
   &$array2  

[ Top ]

static method contains [line 317]

static boolean contains( &$array, &$record, array $array, mixed $record)

Returns true if $array contains $record else it will return false.



Tags:

version:  1.02
since:  0.1.5
access:  public


Overridden in child classes as:

Vector::contains()
Returns true if $this->mixed (the internal array that is managed by the class Vector) contains $record else it will return false.

Parameters:

array   $array   The array in which schould be searched.
mixed   $record   The value which should compare with the records of the array.
   &$array  
   &$record  

[ Top ]

static method deleteRecord [line 78]

static array deleteRecord( integer $int, &$array, array $array)

Removes the record at $int-index.



Tags:

return:  The removed index in an one dimensional array
version:  1.4
since:  0.1.0
access:  public


Parameters:

integer   $int   Index of record to remove.
array   $array   The array in which the record should be removed.
   &$array  

[ Top ]

static method deleteRecordValue [line 97]

static array deleteRecordValue( &$value, &$array, mixed $value, array $array)

Searches the first record of $value. If it is found it will be removed else the unchanged array will be given back.



Tags:

return:  The removed index in an one dimensional array
version:  1.1
since:  0.1.0
access:  public


Overridden in child classes as:

Vector::deleteRecordValue()
Searches the first record of $value. If it is found it will be delete. All entrys behind the deleted record moving up by one position.

Parameters:

mixed   $value   The value that should be searched.
array   $array   The array in which the record should be removed.
   &$value  
   &$array  

[ Top ]

static method flatten [line 223]

static array &flatten( &$array, &$newArray, [integer $preserve_keys = 1], array $array, array $newArray)

Converts a multidimensional array in a one dimensional array.



Tags:

author:  bluej100 at gmail dot com
author:  Daniel Plücken <daniel@debakel.net> (some modifications)
version:  1.0
see:  77671
since:  0.2.1
access:  public


Parameters:

array   $array  
array   $newArray  
integer   $preserve_keys  
   &$array  
   &$newArray  

[ Top ]

static method getFirstIndexOf [line 260]

static integer|false getFirstIndexOf( &$mixedVal, &$array, mixed $mixedVal, array $array)

Returns the position of the first record that matches the value of $mixedVal. If there is not a record that matches the value then the function will return false.



Tags:

version:  1.2
since:  0.1.2
access:  public


Overridden in child classes as:

Vector::getFirstIndexOf()
Returns the position of the first record that matches the value of $mixedVal.

Parameters:

mixed   $mixedVal   The value that should be searched.
array   $array   The array in which the record should be searched.
   &$mixedVal  
   &$array  

[ Top ]

static method getFirstIntegerValue [line 453]

static false|integer getFirstIntegerValue( &$in_arr, array $in_arr)

Returns the first occuring value that is a type of integer.



Tags:

version:  1.0
since:  0.2.8
access:  public


Parameters:

array   $in_arr  
   &$in_arr  

[ Top ]

static method getFirstPregMatchValue [line 480]

static false|string getFirstPregMatchValue( string $str_reg_exp, &$in_arr, array $in_arr)

Returns the first occuring value that matches a regular expression.



Tags:

version:  1.0
since:  0.2.8
access:  public


Parameters:

string   $str_reg_exp  
array   $in_arr  
   &$in_arr  

[ Top ]

static method getIndexAsArray [line 393]

static array getIndexAsArray( integer/string $index, &$array, [boolean $empty_entries = false], array $array)

Returns the given second dimension index of a two dimensional array as

a one dimensional array. Imagine that a two dimensional array is pictured as a table and you want to get all values from a specified col of this table, then you can use this function to do so. It is very helpful to extract all values of a field from a set of data.




Tags:

version:  1.1
since:  0.2.2
access:  public


Parameters:

integer/string   $index  
array   $array   The array of which the index should be extract.
boolean   $empty_entries   Decides wether empty entries should add to the new array or not.
   &$array  

[ Top ]

static method getRandomRecord [line 296]

static array getRandomRecord( array $array)

Returns a random record of given $array. Sets automatically a new random set by microtime for real random.



Tags:

version:  1.0
since:  0.1.7
access:  public


Overridden in child classes as:

Vector::getRandomRecord()
Returns a random record of this vector.

Parameters:

array   $array   The array from which the record should be returned.

[ Top ]

static method getValuesOfKey [line 421]

static array getValuesOfKey( string $str_key_name, &$in_arr, array $in_arr)

Returns the values behind all keys that correspond with the given one.



Tags:

version:  1.0
since:  0.2.8
access:  public


Parameters:

string   $str_key_name  
array   $in_arr  
   &$in_arr  

[ Top ]

static method implodeIndex [line 633]

static string implodeIndex( string $glue, &$array, integer/string $index, [boolean $empty_entries = false], array $array)

Returns a string containing a string representation of all the array elements on index of the arrays second dimension in the same order, with the glue string between each element.



Tags:

version:  1.0
since:  0.2.6
access:  public


Parameters:

string   $glue  
array   $array   The array which elements will be used.
integer/string   $index  
boolean   $empty_entries   Decides wether empty entries should add to the string or not.
   &$array  

[ Top ]

static method integratedAscending [line 582]

static array integratedAscending( array $array, integer $rangeA, integer $rangeB)

Returns whether the records in the array are consecutively numbered in a given range after the array had been sort. This function can be helpful to proof the completeness of data.

Example:

  1.  $arr array354679);
  2.  ifArrays::integratedAscending$arr3) )
  3.    echo "This will surely be output.";
  4.  
  5.  ifArrays::integratedAscending$arr3) )
  6.    echo "This will NOT be output.";
  7.  
  8.  $arr2 array3579);
  9.  ifArrays::integratedAscending$arr23) )
  10.    echo "This will also NOT be output.";




Tags:

version:  1.0
since:  0.1.9
access:  public


Parameters:

array   $array   The array to be probed.
integer   $rangeA   The minimum of the range.
integer   $rangeB   The maximum of the range.

[ Top ]

static method is_empty [line 119]

static boolean is_empty( &$array, array $array)

Returns whether an array is empty. That means every record of the array will be proofed with the function empty().



Tags:

version:  1.21
since:  0.2.0
access:  public


Parameters:

array   $array   The array that should be checked of emptiness.
   &$array  

[ Top ]

static method primaryValueToTuple [line 193]

static array &primaryValueToTuple( &$array, string $value_key, array $array)

Returns a new array with the values from the given key of the second dimension as keys in first dimension refering to the second dimension tuple.

  1.  $data_arr array(
  2.                 => array("id"=>24,"name"=>"Vera","name"=>"Oberkönig"),
  3.                 => array("id"=>17,"name"=>"Daniel","name"=>"Plücken"),
  4.                 => array("id"=>23,"name"=>"Kayleigh","name"=>"Moritz")
  5.                   );
  6.  
  7.  $p_data_arr Arrays::primaryValueToTuple$data_arr"id" );
  8.  
  9.  // now $p_data_arr is:
  10.  $p_data_arr array(
  11.                "24" => array("id"=>24,"name"=>"Vera","name"=>"Oberkönig"),
  12.                "17" => array("id"=>17,"name"=>"Daniel","name"=>"Plücken"),
  13.                "23" => array("id"=>23,"name"=>"Kayleigh","name"=>"Moritz")
  14.                     );




Tags:

version:  1.0
since:  0.2.97
access:  public


Parameters:

array   $array  
string   $value_key  
   &$array  

[ Top ]

static method sortSecondDimension [line 709]

static array &sortSecondDimension( &$array, string $index, [string $func = "strcmp"], array $array)

Sorts an array by a given second index. You can affect the order of

character and strings by defining the constnand ALPHABET and NO_CASE_ALPHABET in the language file which can be found in the package core/lang_spec_values. With defining of the constant LANG, you can switch between the various orders on every new page request.




Tags:

version:  1.0
since:  0.2.3
access:  public


Parameters:

array   $array   The array that should be sort.
string   $index   The index or rather name of the second dimension that should be sort.
string   $func   The suffix of the custum function which should be used (See also the function list of the package core). Possible Values are:
  • boolcmp: To sort boolean values ascending. First cames false, then true.
  • boolcmp_desc: To sort boolean values descending. First cames true, the false.
  • charcmp: To sort character values ascending. The order can be dedicated by defining the constant ALPHABET in the language files that can be found in the package core/lang_spec_values.
  • charcmp_desc: To sort character values descending. The order can be dedicated by defining the constant ALPHABET in the language files that can be found in the package core/lang_spec_values.
  • intcmp: To sort integer values ascending.
  • intcmp_desc To sort integer values descending.
  • strcmp: To sort Strings ascending. The order can be dedicated by defining the constant ALPHABET in the language files that can be found in the package core/lang_spec_values.
  • strcmp_desc: To sort Strings descending. The order can be dedicated by defining the constant ALPHABET in the language files that can be found in the package core/lang_spec_values.
   &$array  

[ Top ]

static method uniqueInsert [line 335]

static void uniqueInsert( &$array, mixed $record, array $array)

Fills $record in $array only if $array does not already contains it.



Tags:

version:  1.01
since:  0.1.2
access:  public


Overridden in child classes as:

Vector::uniqueInsert()
Fills $record in $this->mixed only if $this->mixed does not already contains it.

Parameters:

array   $array   The array in which the record should be filled in.
mixed   $record   The value which should be filled in the array.
   &$array  

[ Top ]

static method uniqueRecords [line 360]

static array uniqueRecords( &$array, array $array)

Removes doubly occuring records in $array and set up new indexes, so that the first index of the array beginns at zero and the other indexes following integrated and ascendending.



Tags:

version:  1.0
since:  0.1.4
access:  public


Overridden in child classes as:

Vector::uniqueRecords()
Removes doubly occuring records in $this->mixed.

Parameters:

array   $array   The array in which each record should be unique.
   &$array  

[ Top ]


Documentation generated on Thu, 05 Jun 2008 19:10:13 +0200 by phpDocumentor 1.4.1