📄 php_ref_array.asp@output=print
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-US" xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>PHP Array Functions</title>
<link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta name="Keywords" content="xml,tutorial,html,dhtml,css,xsl,xhtml,javascript,asp,ado,vbscript,dom,sql,colors,soap,php,authoring,programming,training,learning,beginner's guide,primer,lessons,school,howto,reference,examples,samples,source code,tags,demos,tips,links,FAQ,tag list,forms,frames,color table,w3c,cascading style sheets,active server pages,dynamic html,internet,database,development,Web building,Webmaster,html guide" />
<meta name="Description" content="Free HTML XHTML CSS JavaScript DHTML XML DOM XSL XSLT RSS AJAX ASP ADO PHP SQL tutorials, references, examples for web building." />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "../../https@ssl./default.htm" : "../../www./default.htm");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-3855518-1");
pageTracker._initData();
pageTracker._trackPageview();
</script>
</head>
<body>
<p>From <b>http://www.w3schools.com</b> (Copyright Refsnes Data)</p>
<h1>PHP Array Functions</h1>
<a href="php_ajax_poll.asp"><img alt="previous" border="0" src="../images/btn_previous.gif" width="100" height="20" /></a>
<a href="php_ref_calendar.asp"><img alt="next" border="0" src="../images/btn_next.gif" width="100" height="20" /></a>
<hr />
<h2>PHP Array Introduction</h2>
<p>The array functions allow you to manipulate arrays.</p>
<p>PHP supports both simple and multi-dimensional arrays. There are also
specific functions for populating arrays from database queries.</p>
<hr />
<h2>Installation</h2>
<p>The array functions are part of the PHP core. There is no installation needed
to use these functions.</p>
<hr />
<h2>PHP Array Functions</h2>
<p><b>PHP</b>: indicates the earliest version of PHP that supports the
function. </p>
<table class="ex" cellspacing="0" border="1" width="100%" id="table4">
<tr>
<th width="35%" align="left" valign="top">Function</th>
<th width="60%" align="left" valign="top">Description</th>
<th width="5%" align="left" valign="top">PHP</th>
</tr>
<tr>
<td valign="top"><a href="func_array.asp">array()</a></td>
<td valign="top">Creates an array</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="func_array_change_key_case.asp">array_change_key_case()</a></td>
<td valign="top">Returns an array with all keys in lowercase or uppercase</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="func_array_chunk.asp">array_chunk()</a></td>
<td valign="top">Splits an array into chunks of arrays</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="func_array_combine.asp">array_combine()</a></td>
<td valign="top">Creates an array by using one array for keys and another for its values</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="func_array_count_values.asp">array_count_values()</a></td>
<td valign="top">Returns an array with the number of occurrences for each value</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="func_array_diff.asp">array_diff()</a></td>
<td valign="top">Compares array values, and returns the differences</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="func_array_diff_assoc.asp">array_diff_assoc()</a></td>
<td valign="top">Compares array keys and values, and returns the differences</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="func_array_diff_key.asp">array_diff_key()</a></td>
<td valign="top">Compares array keys, and returns the differences</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="func_array_diff_uassoc.asp">array_diff_uassoc()</a></td>
<td valign="top">Compares array keys and values, with an additional user-made function check, and returns the differences</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="func_array_diff_ukey.asp">array_diff_ukey()</a></td>
<td valign="top">Compares array keys, with an additional user-made function check, and returns the differences</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="func_array_fill.asp">array_fill()</a></td>
<td valign="top">Fills an array with values</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="func_array_filter.asp">array_filter()</a></td>
<td valign="top">Filters elements of an array using a user-made function</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="func_array_flip.asp">array_flip()</a></td>
<td valign="top">Exchanges all keys with their associated values in an array</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="func_array_intersect.asp">array_intersect()</a></td>
<td valign="top">Compares array values, and returns the matches</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="func_array_intersect_assoc.asp">array_intersect_assoc()</a></td>
<td valign="top">Compares array keys and values, and returns the matches</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="func_array_intersect_key.asp">array_intersect_key()</a></td>
<td valign="top">Compares array keys, and returns the matches</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="func_array_intersect_uassoc.asp">array_intersect_uassoc()</a></td>
<td valign="top">Compares array keys and values, with an additional user-made function check, and returns the matches</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="func_array_intersect_ukey.asp">array_intersect_ukey()</a></td>
<td valign="top">Compares array keys, with an additional user-made function check, and returns the matches</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="func_array_key_exists.asp">array_key_exists()</a></td>
<td valign="top">Checks if the specified key exists in the array</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="func_array_keys.asp">array_keys()</a></td>
<td valign="top">Returns all the keys of an array</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="func_array_map.asp">array_map()</a></td>
<td valign="top">Sends each value of an array to a user-made function, which returns new values</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="func_array_merge.asp">array_merge()</a></td>
<td valign="top">Merges one or more arrays into one array</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="func_array_merge_recursive.asp">array_merge_recursive()</a></td>
<td valign="top">Merges one or more arrays into one array</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="func_array_multisort.asp">array_multisort()</a></td>
<td valign="top">Sorts multiple or multi-dimensional arrays</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="func_array_pad.asp">array_pad()</a></td>
<td valign="top">Inserts a specified number of items, with a specified value, to an array</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="func_array_pop.asp">array_pop()</a></td>
<td valign="top">Deletes the last element of an array</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="func_array_product.asp">array_product()</a></td>
<td valign="top">Calculates the product of the values in an array</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="func_array_push.asp">array_push()</a></td>
<td valign="top">Inserts one or more elements to the end of an array</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="func_array_rand.asp">array_rand()</a></td>
<td valign="top">Returns one or more random keys from an array</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="func_array_reduce.asp">array_reduce()</a></td>
<td valign="top">Returns an array as a string, using a user-defined function</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="func_array_reverse.asp">array_reverse()</a></td>
<td valign="top">Returns an array in the reverse order</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="func_array_search.asp">array_search()</a></td>
<td valign="top">Searches an array for a given value and returns the key</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="func_array_shift.asp">array_shift()</a></td>
<td valign="top">Removes the first element from an array, and returns the value of the removed element</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="func_array_slice.asp">array_slice()</a></td>
<td valign="top">Returns selected parts of an array</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="func_array_splice.asp">array_splice()</a></td>
<td valign="top">Removes and replaces specified elements of an array</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="func_array_sum.asp">array_sum()</a></td>
<td valign="top">Returns the sum of the values in an array</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="func_array_udiff.asp">array_udiff()</a></td>
<td valign="top">Compares array values in a user-made function and returns an array</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="func_array_udiff_assoc.asp">array_udiff_assoc()</td>
<td valign="top">Compares array keys, and compares array values in a user-made function, and returns an array</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="func_array_udiff_uassoc.asp">array_udiff_uassoc()</a></td>
<td valign="top">Compares array keys and array values in user-made functions, and returns an array</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="func_array_uintersect.asp">array_uintersect()</a></td>
<td valign="top">Compares array values in a user-made function and returns an array</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="func_array_uintersect_assoc.asp">array_uintersect_assoc()</a></td>
<td valign="top">Compares array keys, and compares array values in a user-made function, and returns an array</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="func_array_uintersect_uassoc.asp">array_uintersect_uassoc()</a></td>
<td valign="top">Compares array keys and array values in user-made functions, and returns an array</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="func_array_unique.asp">array_unique()</a></td>
<td valign="top">Removes duplicate values from an array</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="func_array_unshift.asp">array_unshift()</a></td>
<td valign="top">Adds one or more elements to the beginning of an array</td>
<td valign="top">4</td>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -