PHPLib/docs/classes/PHPUtil.Arr.html
2013-01-31 15:24:10 -05:00

426 lines
20 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html><html xmlns:date="http://exslt.org/dates-and-times" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
<meta charset="utf-8">
<title>PHPLib » \PHPUtil\Arr</title>
<meta name="author" content="Mike van Riel">
<meta name="description" content="">
<link href="../css/template.css" rel="stylesheet" media="all">
<script src="../js/jquery-1.7.1.min.js" type="text/javascript"></script><script src="../js/jquery-ui-1.8.2.custom.min.js" type="text/javascript"></script><script src="../js/jquery.mousewheel.min.js" type="text/javascript"></script><script src="../js/bootstrap.js" type="text/javascript"></script><script src="../js/template.js" type="text/javascript"></script><script src="../js/prettify/prettify.min.js" type="text/javascript"></script><link rel="shortcut icon" href="../img/favicon.ico">
<link rel="apple-touch-icon" href="../img/apple-touch-icon.png">
<link rel="apple-touch-icon" sizes="72x72" href="../img/apple-touch-icon-72x72.png">
<link rel="apple-touch-icon" sizes="114x114" href="../img/apple-touch-icon-114x114.png">
</head>
<body>
<div class="navbar navbar-fixed-top">
<div class="navbar-inner"><div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></a><a class="brand" href="../index.html">PHPLib</a><div class="nav-collapse"><ul class="nav">
<li class="dropdown">
<a href="#api" class="dropdown-toggle" data-toggle="dropdown">
API Documentation <b class="caret"></b></a><ul class="dropdown-menu">
<li><a>Packages</a></li>
<li><a href="../packages/Default.html"><i class="icon-folder-open"></i> Default</a></li>
<li><a href="../packages/PHPLib.html"><i class="icon-folder-open"></i> PHPLib</a></li>
</ul>
</li>
<li class="dropdown" id="charts-menu">
<a href="#charts" class="dropdown-toggle" data-toggle="dropdown">
Charts <b class="caret"></b></a><ul class="dropdown-menu"><li><a href="../graph_class.html"><i class="icon-list-alt"></i> Class hierarchy diagram</a></li></ul>
</li>
<li class="dropdown" id="reports-menu">
<a href="#reports" class="dropdown-toggle" data-toggle="dropdown">
Reports <b class="caret"></b></a><ul class="dropdown-menu">
<li><a href="../errors.html"><i class="icon-remove-sign"></i> Errors 
<span class="label label-info">0</span></a></li>
<li><a href="../markers.html"><i class="icon-map-marker"></i> Markers 
<ul></ul></a></li>
<li><a href="../deprecated.html"><i class="icon-stop"></i> Deprecated elements 
<span class="label label-info">0</span></a></li>
</ul>
</li>
</ul></div>
</div></div>
<div class="go_to_top"><a href="#___" style="color: inherit">Back to top  <i class="icon-upload icon-white"></i></a></div>
</div>
<div id="___" class="container">
<noscript><div class="alert alert-warning">
Javascript is disabled; several features are only available
if Javascript is enabled.
</div></noscript>
<div class="row">
<div class="span4">
<span class="btn-group visibility" data-toggle="buttons-checkbox"><button class="btn public active" title="Show public elements">Public</button><button class="btn protected" title="Show protected elements">Protected</button><button class="btn private" title="Show private elements">Private</button><button class="btn inherited active" title="Show inherited elements">Inherited</button></span><div class="btn-group view pull-right" data-toggle="buttons-radio">
<button class="btn details" title="Show descriptions and method names"><i class="icon-list"></i></button><button class="btn simple" title="Show only method names"><i class="icon-align-justify"></i></button>
</div>
<ul class="side-nav nav nav-list">
<li class="nav-header">
<i class="icon-custom icon-method"></i> Methods</li>
<li class="method public "><a href="#__construct" title="__construct :: Constructor"><span class="description">Constructor</span><pre>__construct()</pre></a></li>
<li class="method public "><a href="#__invoke" title="__invoke :: Enable using the object as a function"><span class="description">Enable using the object as a function</span><pre>__invoke()</pre></a></li>
<li class="method public "><a href="#count_values" title="count_values :: Return an array with keys that are the values of the input
array, and values as the frequency of those values"><span class="description">Return an array with keys that are the values of the input
array, and values as the frequency of those values</span><pre>count_values()</pre></a></li>
<li class="method public "><a href="#fill" title="fill :: Return an array with elements having the defined values"><span class="description">Return an array with elements having the defined values</span><pre>fill()</pre></a></li>
<li class="method public "><a href="#filter" title="filter :: Filter elements of the input array using a callback function"><span class="description">Filter elements of the input array using a callback function</span><pre>filter()</pre></a></li>
<li class="method public "><a href="#flip" title="flip :: Return an array with keys and values reversed from the input array"><span class="description">Return an array with keys and values reversed from the input array</span><pre>flip()</pre></a></li>
<li class="method public "><a href="#grep" title="grep :: Returns an array of elements from the input array that match the
specified pattern"><span class="description">Returns an array of elements from the input array that match the
specified pattern</span><pre>grep()</pre></a></li>
<li class="method public "><a href="#keys" title="keys :: Return the keys or a subset of the keys of an array"><span class="description">Return the keys or a subset of the keys of an array</span><pre>keys()</pre></a></li>
<li class="method public "><a href="#merge" title="merge :: Combine arrays
(Takes a variable number of arguments)"><span class="description">Combine arrays
(Takes a variable number of arguments)</span><pre>merge()</pre></a></li>
<li class="method public "><a href="#pad" title="pad :: Lengthen array to $pad_length with $pad_value"><span class="description">Lengthen array to $pad_length with $pad_value</span><pre>pad()</pre></a></li>
<li class="method public "><a href="#replace" title="replace :: Replace elements in the main array with the values in the passed arrays
(Takes a variable number of arguments)"><span class="description">Replace elements in the main array with the values in the passed arrays
(Takes a variable number of arguments)</span><pre>replace()</pre></a></li>
<li class="method public "><a href="#reverse" title="reverse :: Reverse the order of the array"><span class="description">Reverse the order of the array</span><pre>reverse()</pre></a></li>
<li class="method public "><a href="#reverse_sort" title="reverse_sort :: Return a reverse-sorted array"><span class="description">Return a reverse-sorted array</span><pre>reverse_sort()</pre></a></li>
<li class="method public "><a href="#sort" title="sort :: Return a sorted array"><span class="description">Return a sorted array</span><pre>sort()</pre></a></li>
<li class="method public "><a href="#sum" title="sum :: Returns the sum of all the values in the array"><span class="description">Returns the sum of all the values in the array</span><pre>sum()</pre></a></li>
<li class="method public "><a href="#unique" title="unique :: Return a new array from the original with duplicate items removed"><span class="description">Return a new array from the original with duplicate items removed</span><pre>unique()</pre></a></li>
<li class="method public "><a href="#values" title="values :: Returns the values from the input array with a numeric index"><span class="description">Returns the values from the input array with a numeric index</span><pre>values()</pre></a></li>
<li class="nav-header">
<i class="icon-custom icon-property"></i> Properties</li>
<li class="nav-header protected">» Protected</li>
<li class="property protected "><a href="#%24original" title="$original :: Original array to manipulate"><span class="description">Original array to manipulate</span><pre>$original</pre></a></li>
</ul>
</div>
<div class="span8">
<a name="%5CPHPUtil%5CArr" id="\PHPUtil\Arr"></a><ul class="breadcrumb">
<li>
<a href="../index.html"><i class="icon-custom icon-class"></i></a><span class="divider">\</span>
</li>
<li><a href="../namespaces/PHPUtil.html">PHPUtil</a></li>
<li class="active">
<span class="divider">\</span><a href="../classes/PHPUtil.Arr.html">Arr</a>
</li>
</ul>
<div href="../classes/PHPUtil.Arr.html" class="element class">
<p class="short_description">Wrapper over array functions with a consistent interface</p>
<div class="details">
<p class="long_description"></p>
<h3>
<i class="icon-custom icon-method"></i> Methods</h3>
<a name="__construct" id="__construct"></a><div class="element clickable method public __construct" data-toggle="collapse" data-target=".__construct .collapse">
<h2>Constructor</h2>
<pre>__construct(array $arr) : <a href="../classes/PHPUtil.Arr.html">\PHPUtil\Arr</a></pre>
<div class="labels"></div>
<div class="row collapse"><div class="span8">
<p class="long_description"></p>
<h3>Parameters</h3>
<div class="subelement argument">
<h4>$arr</h4>
<code>array</code>
</div>
<h3>Returns</h3>
<div class="subelement response"><code><a href="../classes/PHPUtil.Arr.html">\PHPUtil\Arr</a></code></div>
</div></div>
</div>
<a name="__invoke" id="__invoke"></a><div class="element clickable method public __invoke" data-toggle="collapse" data-target=".__invoke .collapse">
<h2>Enable using the object as a function</h2>
<pre>__invoke(string $arr) : \PHPUtil\$this</pre>
<div class="labels"></div>
<div class="row collapse"><div class="span8">
<p class="long_description"></p>
<h3>Parameters</h3>
<div class="subelement argument">
<h4>$arr</h4>
<code>string</code>
</div>
<h3>Returns</h3>
<div class="subelement response"><code>\PHPUtil\$this</code></div>
</div></div>
</div>
<a name="count_values" id="count_values"></a><div class="element clickable method public count_values" data-toggle="collapse" data-target=".count_values .collapse">
<h2>Return an array with keys that are the values of the input
array, and values as the frequency of those values</h2>
<pre>count_values() : array</pre>
<div class="labels"></div>
<div class="row collapse"><div class="span8">
<p class="long_description"></p>
<table class="table table-bordered"><tr>
<th>see</th>
<td>\PHPUtil\http://php.net/manual/function.array-count-values.php</td>
</tr></table>
<h3>Returns</h3>
<div class="subelement response"><code>array</code></div>
</div></div>
</div>
<a name="fill" id="fill"></a><div class="element clickable method public fill" data-toggle="collapse" data-target=".fill .collapse">
<h2>Return an array with elements having the defined values</h2>
<pre>fill(int $start_index, int $num, mixed $value) : array</pre>
<div class="labels"></div>
<div class="row collapse"><div class="span8">
<p class="long_description"></p>
<table class="table table-bordered"><tr>
<th>see</th>
<td>\PHPUtil\http://php.net/manual/function.array-fill.php</td>
</tr></table>
<h3>Parameters</h3>
<div class="subelement argument">
<h4>$start_index</h4>
<code>int</code>
</div>
<div class="subelement argument">
<h4>$num</h4>
<code>int</code>
</div>
<div class="subelement argument">
<h4>$value</h4>
<code>mixed</code>
</div>
<h3>Returns</h3>
<div class="subelement response"><code>array</code></div>
</div></div>
</div>
<a name="filter" id="filter"></a><div class="element clickable method public filter" data-toggle="collapse" data-target=".filter .collapse">
<h2>Filter elements of the input array using a callback function</h2>
<pre>filter(\PHPUtil\callable $callback) : array</pre>
<div class="labels"></div>
<div class="row collapse"><div class="span8">
<p class="long_description"></p>
<table class="table table-bordered"><tr>
<th>see</th>
<td>\PHPUtil\http://php.net/manual/function.array-filter.php</td>
</tr></table>
<h3>Parameters</h3>
<div class="subelement argument">
<h4>$callback</h4>
<code>\PHPUtil\callable</code>
</div>
<h3>Returns</h3>
<div class="subelement response"><code>array</code></div>
</div></div>
</div>
<a name="flip" id="flip"></a><div class="element clickable method public flip" data-toggle="collapse" data-target=".flip .collapse">
<h2>Return an array with keys and values reversed from the input array</h2>
<pre>flip() : array</pre>
<div class="labels"></div>
<div class="row collapse"><div class="span8">
<p class="long_description"></p>
<table class="table table-bordered"><tr>
<th>see</th>
<td>\PHPUtil\http://php.net/manual/function.array-flip.php</td>
</tr></table>
<h3>Returns</h3>
<div class="subelement response"><code>array</code></div>
</div></div>
</div>
<a name="grep" id="grep"></a><div class="element clickable method public grep" data-toggle="collapse" data-target=".grep .collapse">
<h2>Returns an array of elements from the input array that match the
specified pattern</h2>
<pre>grep(mixed $pattern, mixed $invert) : array</pre>
<div class="labels"></div>
<div class="row collapse"><div class="span8">
<p class="long_description"></p>
<h3>Parameters</h3>
<div class="subelement argument">
<h4>$pattern</h4>
<code>mixed</code>
</div>
<div class="subelement argument">
<h4>$invert</h4>
<code>mixed</code>
</div>
<h3>Returns</h3>
<div class="subelement response"><code>array</code></div>
</div></div>
</div>
<a name="keys" id="keys"></a><div class="element clickable method public keys" data-toggle="collapse" data-target=".keys .collapse">
<h2>Return the keys or a subset of the keys of an array</h2>
<pre>keys(mixed $search_value, bool $strict) : array</pre>
<div class="labels"></div>
<div class="row collapse"><div class="span8">
<p class="long_description"></p>
<table class="table table-bordered"><tr>
<th>see</th>
<td>\PHPUtil\http://php.net/manual/function.array-keys.php</td>
</tr></table>
<h3>Parameters</h3>
<div class="subelement argument">
<h4>$search_value</h4>
<code>mixed</code>
</div>
<div class="subelement argument">
<h4>$strict</h4>
<code>bool</code>
</div>
<h3>Returns</h3>
<div class="subelement response"><code>array</code></div>
</div></div>
</div>
<a name="merge" id="merge"></a><div class="element clickable method public merge" data-toggle="collapse" data-target=".merge .collapse">
<h2>Combine arrays
(Takes a variable number of arguments)</h2>
<pre>merge() : array</pre>
<div class="labels"></div>
<div class="row collapse"><div class="span8">
<p class="long_description"></p>
<table class="table table-bordered"><tr>
<th>see</th>
<td>\PHPUtil\http://php.net/manual/function.array-merge.php</td>
</tr></table>
<h3>Returns</h3>
<div class="subelement response"><code>array</code></div>
</div></div>
</div>
<a name="pad" id="pad"></a><div class="element clickable method public pad" data-toggle="collapse" data-target=".pad .collapse">
<h2>Lengthen array to $pad_length with $pad_value</h2>
<pre>pad(int $pad_size, mixed $pad_value) : array</pre>
<div class="labels"></div>
<div class="row collapse"><div class="span8">
<p class="long_description"></p>
<table class="table table-bordered"><tr>
<th>see</th>
<td>\PHPUtil\http://php.net/manual/function.array-pad.php</td>
</tr></table>
<h3>Parameters</h3>
<div class="subelement argument">
<h4>$pad_size</h4>
<code>int</code>
</div>
<div class="subelement argument">
<h4>$pad_value</h4>
<code>mixed</code>
</div>
<h3>Returns</h3>
<div class="subelement response"><code>array</code></div>
</div></div>
</div>
<a name="replace" id="replace"></a><div class="element clickable method public replace" data-toggle="collapse" data-target=".replace .collapse">
<h2>Replace elements in the main array with the values in the passed arrays
(Takes a variable number of arguments)</h2>
<pre>replace() : array</pre>
<div class="labels"></div>
<div class="row collapse"><div class="span8">
<p class="long_description"></p>
<table class="table table-bordered"><tr>
<th>see</th>
<td>\PHPUtil\http://php.net/manual/function.array-replace.php</td>
</tr></table>
<h3>Returns</h3>
<div class="subelement response"><code>array</code></div>
</div></div>
</div>
<a name="reverse" id="reverse"></a><div class="element clickable method public reverse" data-toggle="collapse" data-target=".reverse .collapse">
<h2>Reverse the order of the array</h2>
<pre>reverse(bool $preserve_keys) : array</pre>
<div class="labels"></div>
<div class="row collapse"><div class="span8">
<p class="long_description"></p>
<table class="table table-bordered"><tr>
<th>see</th>
<td>\PHPUtil\http://php.net/manual/function.array-reverse.php</td>
</tr></table>
<h3>Parameters</h3>
<div class="subelement argument">
<h4>$preserve_keys</h4>
<code>bool</code>
</div>
<h3>Returns</h3>
<div class="subelement response"><code>array</code></div>
</div></div>
</div>
<a name="reverse_sort" id="reverse_sort"></a><div class="element clickable method public reverse_sort" data-toggle="collapse" data-target=".reverse_sort .collapse">
<h2>Return a reverse-sorted array</h2>
<pre>reverse_sort(int $sort_flags) : array</pre>
<div class="labels"></div>
<div class="row collapse"><div class="span8">
<p class="long_description"></p>
<table class="table table-bordered"><tr>
<th>see</th>
<td>\PHPUtil\http://php.net/manual/function.asort.php</td>
</tr></table>
<h3>Parameters</h3>
<div class="subelement argument">
<h4>$sort_flags</h4>
<code>int</code>
</div>
<h3>Returns</h3>
<div class="subelement response"><code>array</code></div>
</div></div>
</div>
<a name="sort" id="sort"></a><div class="element clickable method public sort" data-toggle="collapse" data-target=".sort .collapse">
<h2>Return a sorted array</h2>
<pre>sort(int $sort_flags) : array</pre>
<div class="labels"></div>
<div class="row collapse"><div class="span8">
<p class="long_description"></p>
<table class="table table-bordered"><tr>
<th>see</th>
<td>\PHPUtil\http://php.net/manual/function.asort.php</td>
</tr></table>
<h3>Parameters</h3>
<div class="subelement argument">
<h4>$sort_flags</h4>
<code>int</code>
</div>
<h3>Returns</h3>
<div class="subelement response"><code>array</code></div>
</div></div>
</div>
<a name="sum" id="sum"></a><div class="element clickable method public sum" data-toggle="collapse" data-target=".sum .collapse">
<h2>Returns the sum of all the values in the array</h2>
<pre>sum() : \PHPUtil\number</pre>
<div class="labels"></div>
<div class="row collapse"><div class="span8">
<p class="long_description"></p>
<table class="table table-bordered"><tr>
<th>see</th>
<td>\PHPUtil\http://php.net/manual/function.array-sum.php</td>
</tr></table>
<h3>Returns</h3>
<div class="subelement response"><code>\PHPUtil\number</code></div>
</div></div>
</div>
<a name="unique" id="unique"></a><div class="element clickable method public unique" data-toggle="collapse" data-target=".unique .collapse">
<h2>Return a new array from the original with duplicate items removed</h2>
<pre>unique($sort_flags) : array</pre>
<div class="labels"></div>
<div class="row collapse"><div class="span8">
<p class="long_description"></p>
<table class="table table-bordered"><tr>
<th>see</th>
<td>\PHPUtil\http://php.net/manual/function.array-unique.php</td>
</tr></table>
<h3>Parameters</h3>
<div class="subelement argument">
<h4>$sort_flags</h4>
<code></code>
</div>
<h3>Returns</h3>
<div class="subelement response"><code>array</code></div>
</div></div>
</div>
<a name="values" id="values"></a><div class="element clickable method public values" data-toggle="collapse" data-target=".values .collapse">
<h2>Returns the values from the input array with a numeric index</h2>
<pre>values() : array</pre>
<div class="labels"></div>
<div class="row collapse"><div class="span8">
<p class="long_description"></p>
<h3>Returns</h3>
<div class="subelement response"><code>array</code></div>
</div></div>
</div>
<h3>
<i class="icon-custom icon-property"></i> Properties</h3>
<a name="%24original" id="$original"> </a><div class="element clickable property protected $original" data-toggle="collapse" data-target=".$original .collapse">
<h2>Original array to manipulate</h2>
<pre>$original : array</pre>
<div class="labels"></div>
<div class="row collapse"><div class="span8"><p class="long_description"></p></div></div>
</div>
</div>
</div>
</div>
</div>
<div class="row"><footer class="span12">
Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a2</a> and<br>
generated on 2013-01-31T15:19:19-05:00.<br></footer></div>
</div>
</body>
</html>