<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Hiro技术站 &#187; PHP</title>
	<atom:link href="http://www.ihiro.org/tag/php/feed" rel="self" type="application/rss+xml" />
	<link>http://www.ihiro.org</link>
	<description></description>
	<lastBuildDate>Fri, 06 Jan 2012 07:58:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>PHP:pathinfo()获得文件的路径、名称等信息</title>
		<link>http://www.ihiro.org/pathinfo-to-obtain-filepath-and-filename</link>
		<comments>http://www.ihiro.org/pathinfo-to-obtain-filepath-and-filename#comments</comments>
		<pubDate>Fri, 11 Dec 2009 07:15:58 +0000</pubDate>
		<dc:creator>Hiro</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[后台编程]]></category>
		<category><![CDATA[学习笔记]]></category>

		<guid isPermaLink="false">http://www.ihiro.org/?p=926</guid>
		<description><![CDATA[<img src="http://www.ihiro.org/blog/wp-content/uploads/2009/12/path-logo.png" alt="path-logo" title="path-logo" width="100" height="100" class="alignleft size-full wp-image-929" />
<p>最近试图着去阅读一些PHP编程的资料，希望通过学习可以掌握好这门开源的后台编程语言。函数是编程语言的主要组成，所以多熟悉PHP语言内部函数的应用和意义，对我以后的PHP编程意义重大。</p>
<p>近两个月来我的js编程有了很大的提高，在借助与jQuery库的帮助下，着实写出了一些很多行实用的代码，运用到了项目中。所以我有了一个想法，我想我的下一个WP主题要使用大量的js来是想效果，运用一些Ajax的特性，使得我的博客更加地人性化。但因PHP编程不熟的原因所以只能推迟。</p>
<p>在PHP中，若想通过函数获得一个文件的路径、名称，或者是扩展名等，是非常容易的一件事。可以使用dirname()、basename()、pathinfo()等多种途径获得相应的信息。</p>
<p style="color:#f00;">该文内容为个人学习之用，不关心的朋友可以不做理会！</p>]]></description>
			<content:encoded><![CDATA[<p>最近试图着去阅读一些PHP编程的资料，希望通过学习可以掌握好这门开源的后台编程语言。函数是编程语言的主要组成，所以多熟悉PHP语言内部函数的应用和意义，对我以后的PHP编程意义重大。</p>
<p>近两个月来我的js编程有了很大的提高，在借助与jQuery库的帮助下，着实写出了一些很多行实用的代码，运用到了项目中。所以我有了一个想法，我想我的下一个WP主题要使用大量的js来是想效果，运用一些Ajax的特性，使得我的博客更加地人性化。但因PHP编程不熟的原因所以只能推迟。</p>
<p>废话不说了，进入主题。</p>
<p>在PHP中，若想通过函数获得一个文件的路径、名称，或者是扩展名等，是非常容易的一件事。可以使用dirname()、basename()、pathinfo()等多种途径获得相应的信息。假设现在有一个图片文件，它的服务器端路径为：</p>

<div class="wp_codebox"><table><tr id="p9261"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p926code1"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$path</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;/www/mywebsite/images/myphoto.jpg&quot;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

</p>
<h3>1.pathinfo()函数</h3>
<p>pathinfo()函数返回的是一个包含了文件信息的数组，数组中有四个元素，分别是dirname、basename、extension、filename。打印数组的代码：</p>

<div class="wp_codebox"><table><tr id="p9262"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p926code2"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$fileArr</span> <span style="color: #339933;">=</span> <span style="color: #990000;">pathinfo</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$path</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fileArr</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//输出结果：Array ( [dirname] =&gt; /www/mywebsite/images [basename] =&gt; myphoto.jpg [extension] =&gt; jpg [filename] =&gt; myphoto )</span></pre></td></tr></table></div>

<p>这样我们只需根据数组的键名就可以获得对应的键值：</p>

<div class="wp_codebox"><table><tr id="p9263"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p926code3"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">echo</span> <span style="color: #000088;">$fileArr</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'filename'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//输出结果：myphoto  </span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$fileArr</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'extension'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//输出结果：jpg</span>
<span style="color: #666666; font-style: italic;">//...</span></pre></td></tr></table></div>

</p>
<h3>2.dirname()函数</h3>
<p>dirname()函数给出一个包含有指向一个文件的全路径的字符串，它返回的值去掉文件名后的目录名，可以认为是对pathinfo()函数的扩展：</p>

<div class="wp_codebox"><table><tr id="p9264"><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code" id="p926code4"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">echo</span> <span style="color: #990000;">dirname</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$path</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//输出结果：/www/mywebsite/images</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//或者</span>
<span style="color: #b1b100;">echo</span> <span style="color: #990000;">dirname</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/www/mywebsite/images/&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
<span style="color: #b1b100;">echo</span> <span style="color: #990000;">dirname</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/www/mywebsite/images&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//输出的结果都为：/www/mywebsite</span></pre></td></tr></table></div>

<p>所以可以理解为返回的值为路径的上一层目录地址名。
</p>
<h3>3.basename()函数</h3>
<p>basename()函数给出一个包含有指向一个文件的全路径的字符串，他返回的值为基本的文件名，同样可以认为是对pathinfo()函数的扩展：</p>

<div class="wp_codebox"><table><tr id="p9265"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p926code5"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">echo</span> <span style="color: #990000;">basename</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$path</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//输出结果：myphoto.jpg</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//或者</span>
<span style="color: #990000;">basename</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/www/mywebsite/images/&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//输出结果：images</span></pre></td></tr></table></div>

<p>所以可以理解为返回的值为路径的当前目录的名称。
</p>
<p style="color:#f00;">该文内容为个人学习之用，不关心的朋友可以不做理会！</p>
<h2  class="related_post_title">你也许会喜欢阅读这些：</h2><ul class="related_post"><li>2009年08月20日 -- <a href="http://www.ihiro.org/array-sort-function" title="PHP:数组排序函数大总结">PHP:数组排序函数大总结</a> (6)</li><li>2011年04月20日 -- <a href="http://www.ihiro.org/css3-transition" title="CSS3:Transition属性详解">CSS3:Transition属性详解</a> (82)</li><li>2011年04月1日 -- <a href="http://www.ihiro.org/html5-reading-note-chp4-canvas" title="HTML5:《HTML5. Up and Running》读书笔记.Chp4.Canvas">HTML5:《HTML5. Up and Running》读书笔记.Chp4.Canvas</a> (22)</li><li>2011年03月21日 -- <a href="http://www.ihiro.org/html5-reading-note-chp3-elements" title="HTML5:《HTML5. Up and Running》读书笔记.Chp3.Elements">HTML5:《HTML5. Up and Running》读书笔记.Chp3.Elements</a> (24)</li><li>2011年03月15日 -- <a href="http://www.ihiro.org/html5-reading-note-chp2-features" title="HTML5:《HTML5. Up and Running》读书笔记.Chp2.Features">HTML5:《HTML5. Up and Running》读书笔记.Chp2.Features</a> (23)</li><li>2010年12月7日 -- <a href="http://www.ihiro.org/beginning-python" title="Python:Beginning Python['paiθən]">Python:Beginning Python['paiθən]</a> (27)</li><li>2010年11月22日 -- <a href="http://www.ihiro.org/text-range" title="Range:文本框选区学习笔记">Range:文本框选区学习笔记</a> (16)</li><li>2010年08月12日 -- <a href="http://www.ihiro.org/sizzle-custom-selector" title="Sizzle:开源JS选择器，如何自定义选择器">Sizzle:开源JS选择器，如何自定义选择器</a> (31)</li><li>2009年11月25日 -- <a href="http://www.ihiro.org/wordpress-the-article-automatically-appear-as-two" title="Wordpress:将文章自动显示为两列">Wordpress:将文章自动显示为两列</a> (13)</li><li>2009年09月10日 -- <a href="http://www.ihiro.org/javascript-oop" title="Javascript:面向对象之静态、公有、私有、特权对象">Javascript:面向对象之静态、公有、私有、特权对象</a> (10)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.ihiro.org/pathinfo-to-obtain-filepath-and-filename/feed</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>PHP:数组排序函数大总结</title>
		<link>http://www.ihiro.org/array-sort-function</link>
		<comments>http://www.ihiro.org/array-sort-function#comments</comments>
		<pubDate>Thu, 20 Aug 2009 10:06:16 +0000</pubDate>
		<dc:creator>Hiro</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[学习笔记]]></category>

		<guid isPermaLink="false">http://www.ihiro.org/?p=461</guid>
		<description><![CDATA[<img src="http://www.ihiro.org/blog/wp-content/uploads/2009/08/array.jpg" alt="array" title="array" width="100" height="100" class="alignleft wp-image-462" />
<p>上周去得到一个面试题，题目是这样的：PHP中sort()、asort()、ksort()函数之前的区别是什么，在什么情况下改用哪个函数？我当时的答案就不在这公布了，呵呵，总之不对的。</p>
<p>回来后一直在揪心啊，于是翻了一下书本查阅，给我知道了答案。为了记住它们，我决定来一个数组排序函数大总结。</p>
<p>数组排序函数大全：sort()、rsort()、asort()、arsort()、ksort()、krsort()、reverse_array()、shuffle()、usort()等</p>]]></description>
			<content:encoded><![CDATA[<p>上周去得到一个面试题，题目是这样的：PHP中sort()、asort()、ksort()函数之前的区别是什么，在什么情况下改用哪个函数？我当时的答案就不在这公布了，呵呵，总之不对的。</p>
<p>回来后一直在揪心啊，于是翻了一下书本查阅，给我知道了答案。为了记住它们，我决定来一个数组排序函数大总结。</p>
<h3>一、一维数组</h3>
<p>假设有一个一维数组，如下：</p>

<div class="wp_codebox"><table><tr id="p4616"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p461code6"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$sortArr</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;name&quot;</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">&quot;hiro&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;age&quot;</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">&quot;23&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;city&quot;</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">&quot;Shanghai&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;code&quot;</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">&quot;200051&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>print_r()输出的原始数组结果为：</p>

<div class="wp_codebox"><table><tr id="p4617"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p461code7"><pre class="html" style="font-family:monospace;">Array ( [name] =&gt; hiro [age] =&gt; 23 [city] =&gt; Shanghai [code] =&gt; 200051 )</pre></td></tr></table></div>

</p>
<p>1.<strong>sort()函数:</strong>根据数组下标进行升序排列；<br />
print_r()输出的数组结果为(输出时只有数组下标，而不是键名)：</p>

<div class="wp_codebox"><table><tr id="p4618"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p461code8"><pre class="html" style="font-family:monospace;">Array ( [0] =&gt; 23 [1] =&gt; 200051 [2] =&gt; Shanghai [3] =&gt; hiro )</pre></td></tr></table></div>

</p>
<p>2.<strong>rsort()函数:</strong>与sort()函数相反，根据数组下标进行降序排列；<br />
print_r()输出的数组结果为(输出时只有数组下标，而不是键名)：</p>

<div class="wp_codebox"><table><tr id="p4619"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p461code9"><pre class="html" style="font-family:monospace;">Array ( [0] =&gt; hiro [1] =&gt; Shanghai [2] =&gt; 200051 [3] =&gt; 23 )</pre></td></tr></table></div>

</p>
<p>3.<strong>asort()函数:</strong>根据数组的键名进行升序排列；<br />
print_r()输出的数组结果为：</p>

<div class="wp_codebox"><table><tr id="p46110"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p461code10"><pre class="html" style="font-family:monospace;">Array ( [age] =&gt; 23 [code] =&gt; 200051 [city] =&gt; Shanghai [name] =&gt; hiro )</pre></td></tr></table></div>

</p>
<p>4.<strong>arsort()函数:</strong>与asort()函数相反，根据数组的键名进行降序排列；<br />
print_r()输出的数组结果为：</p>

<div class="wp_codebox"><table><tr id="p46111"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p461code11"><pre class="html" style="font-family:monospace;">Array ( [name] =&gt; hiro [city] =&gt; Shanghai [code] =&gt; 200051 [age] =&gt; 23 )</pre></td></tr></table></div>

</p>
<p>5.<strong>ksort()函数:</strong>根据数组的键值进行升序排列；<br />
print_r()输出的数组结果为：</p>

<div class="wp_codebox"><table><tr id="p46112"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p461code12"><pre class="html" style="font-family:monospace;">Array ( [age] =&gt; 23 [city] =&gt; Shanghai [code] =&gt; 200051 [name] =&gt; hiro )</pre></td></tr></table></div>

</p>
<p>6.<strong>krsort()函数:</strong>与ksort()函数相反，根据数组的键值进行降序排列；<br />
print_r()输出的数组结果为：</p>

<div class="wp_codebox"><table><tr id="p46113"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p461code13"><pre class="html" style="font-family:monospace;">Array ( [name] =&gt; hiro [city] =&gt; Shanghai [code] =&gt; 200051 [age] =&gt; 23 )</pre></td></tr></table></div>

</p>
<p>7.<strong>reverse_array()函数:</strong>反向当前的数组排列顺序；<br />
print_r()输出的数组结果为：</p>

<div class="wp_codebox"><table><tr id="p46114"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p461code14"><pre class="html" style="font-family:monospace;">Array ( [name] =&gt; hiro [age] =&gt; 23 [city] =&gt; Shanghai [code] =&gt; 200051 )</pre></td></tr></table></div>

</p>
<p>8.<strong>shuffle()函数:</strong>随机地排列数组顺序（每次刷新后排列的顺序都不相同）；<br />
print_r()输出的数组结果为(只是其中一种随机排列)：</p>

<div class="wp_codebox"><table><tr id="p46115"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p461code15"><pre class="html" style="font-family:monospace;">Array ( [0] =&gt; 23 [1] =&gt; 200051 [2] =&gt; Shanghai [3] =&gt; hiro )</pre></td></tr></table></div>

</p>
<h3>二、二维数组</h3>
<p>假设有一个二维数组，如下：</p>

<div class="wp_codebox"><table><tr id="p46116"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p461code16"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$person</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
	<span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;hiro&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;23&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;suzhou&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	<span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;yoyo&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;25&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;shanghai&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	<span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;janstar&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;28&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;xinjiang&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>print_r()输出的原始数组结果为：</p>

<div class="wp_codebox"><table><tr id="p46117"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p461code17"><pre class="html" style="font-family:monospace;">Array ( [0] =&gt; Array ( [0] =&gt; hiro [1] =&gt; 23 [2] =&gt; suzhou ) [1] =&gt; Array ( [0] =&gt; yoyo [1] =&gt; 25 [2] =&gt; shanghai ) [2] =&gt; Array ( [0] =&gt; janstar [1] =&gt; 28 [2] =&gt; xinjiang ) )</pre></td></tr></table></div>

</p>
<p>二维数组的排序是根据每维的键名排序的，所以需要额外地编写比较函数。先举三个例子：</p>
<p>1.按每维的第一个元素升序排列，代码如下:</p>

<div class="wp_codebox"><table><tr id="p46118"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code" id="p461code18"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> compare0<span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$y</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$t</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$y</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #990000;">usort</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$person</span><span style="color: #339933;">,</span> compare0<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;按第一个元素正向排序：&quot;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$person</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>输出的结果如下：
</pre>

<div class="wp_codebox"><table><tr id="p46119"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p461code19"><pre class="html" style="font-family:monospace;">按第一个元素正向排序：Array ( [0] =&gt; Array ( [0] =&gt; hiro [1] =&gt; 23 [2] =&gt; suzhou ) [1] =&gt; Array ( [0] =&gt; janstar [1] =&gt; 28 [2] =&gt; xinjiang ) [2] =&gt; Array ( [0] =&gt; yoyo [1] =&gt; 25 [2] =&gt; shanghai ) )</pre></td></tr></table></div>

</p>
<p>2.按每维的第三个元素升序排列，代码如下:</p>

<div class="wp_codebox"><table><tr id="p46120"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code" id="p461code20"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> compare2<span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$y</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$t</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$y</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #990000;">usort</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$person</span><span style="color: #339933;">,</span> compare2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;按第三个元素正向排序：&quot;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$person</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>输出的结果如下：
</pre>

<div class="wp_codebox"><table><tr id="p46121"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p461code21"><pre class="html" style="font-family:monospace;">按第三个元素正向排序：Array ( [0] =&gt; Array ( [0] =&gt; yoyo [1] =&gt; 25 [2] =&gt; shanghai ) [1] =&gt; Array ( [0] =&gt; hiro [1] =&gt; 23 [2] =&gt; suzhou ) [2] =&gt; Array ( [0] =&gt; janstar [1] =&gt; 28 [2] =&gt; xinjiang ) )</pre></td></tr></table></div>

</p>
<p>3.按每维的第三个元素升序排列，代码如下:</p>

<div class="wp_codebox"><table><tr id="p46122"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code" id="p461code22"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> reverse_compare2<span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$y</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$t</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$y</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>	<span style="color: #666666; font-style: italic;">//改变后即可反向</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>	<span style="color: #666666; font-style: italic;">//改变后即可反向</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #990000;">usort</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$person</span><span style="color: #339933;">,</span> reverse_compare2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;按第三个元素反向排序：&quot;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$person</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>输出的结果如下：
</pre>

<div class="wp_codebox"><table><tr id="p46123"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p461code23"><pre class="html" style="font-family:monospace;">按第三个元素反向排序：Array ( [0] =&gt; Array ( [0] =&gt; janstar [1] =&gt; 28 [2] =&gt; xinjiang ) [1] =&gt; Array ( [0] =&gt; hiro [1] =&gt; 23 [2] =&gt; suzhou ) [2] =&gt; Array ( [0] =&gt; yoyo [1] =&gt; 25 [2] =&gt; shanghai ) )</pre></td></tr></table></div>

</p>
<p>呵呵，是不是代码多了点，记下了以后方便查阅啊！</p>
<h2  class="related_post_title">你也许会喜欢阅读这些：</h2><ul class="related_post"><li>2009年12月11日 -- <a href="http://www.ihiro.org/pathinfo-to-obtain-filepath-and-filename" title="PHP:pathinfo()获得文件的路径、名称等信息">PHP:pathinfo()获得文件的路径、名称等信息</a> (20)</li><li>2011年04月20日 -- <a href="http://www.ihiro.org/css3-transition" title="CSS3:Transition属性详解">CSS3:Transition属性详解</a> (82)</li><li>2011年04月1日 -- <a href="http://www.ihiro.org/html5-reading-note-chp4-canvas" title="HTML5:《HTML5. Up and Running》读书笔记.Chp4.Canvas">HTML5:《HTML5. Up and Running》读书笔记.Chp4.Canvas</a> (22)</li><li>2011年03月21日 -- <a href="http://www.ihiro.org/html5-reading-note-chp3-elements" title="HTML5:《HTML5. Up and Running》读书笔记.Chp3.Elements">HTML5:《HTML5. Up and Running》读书笔记.Chp3.Elements</a> (24)</li><li>2011年03月15日 -- <a href="http://www.ihiro.org/html5-reading-note-chp2-features" title="HTML5:《HTML5. Up and Running》读书笔记.Chp2.Features">HTML5:《HTML5. Up and Running》读书笔记.Chp2.Features</a> (23)</li><li>2010年11月22日 -- <a href="http://www.ihiro.org/text-range" title="Range:文本框选区学习笔记">Range:文本框选区学习笔记</a> (16)</li><li>2010年08月12日 -- <a href="http://www.ihiro.org/sizzle-custom-selector" title="Sizzle:开源JS选择器，如何自定义选择器">Sizzle:开源JS选择器，如何自定义选择器</a> (31)</li><li>2009年11月25日 -- <a href="http://www.ihiro.org/wordpress-the-article-automatically-appear-as-two" title="Wordpress:将文章自动显示为两列">Wordpress:将文章自动显示为两列</a> (13)</li><li>2009年09月10日 -- <a href="http://www.ihiro.org/javascript-oop" title="Javascript:面向对象之静态、公有、私有、特权对象">Javascript:面向对象之静态、公有、私有、特权对象</a> (10)</li><li>2009年08月18日 -- <a href="http://www.ihiro.org/zend-studio-7" title="软件:用上了Zend Studio 7.0，分享序列号">软件:用上了Zend Studio 7.0，分享序列号</a> (10)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.ihiro.org/array-sort-function/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>软件:用上了Zend Studio 7.0，分享序列号</title>
		<link>http://www.ihiro.org/zend-studio-7</link>
		<comments>http://www.ihiro.org/zend-studio-7#comments</comments>
		<pubDate>Tue, 18 Aug 2009 02:51:42 +0000</pubDate>
		<dc:creator>Hiro</dc:creator>
				<category><![CDATA[开发软件]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[开发工具]]></category>
		<category><![CDATA[软件]]></category>

		<guid isPermaLink="false">http://www.ihiro.org/?p=455</guid>
		<description><![CDATA[<img src="http://www.ihiro.org/blog/wp-content/uploads/2009/08/zend-studio.logo.jpg" alt="zend-studio.logo" title="zend-studio.logo" width="100" height="100" class="alignleft wp-image-457" />
<p>前段时间zend网站老是给我发送zend studio 7的推荐下载的邮件（因为我注册过zend官网的原因吧），一直没有理会。前两天无事，便去下载了最新版的zend studio 7。下载时已经是正式版了，文件不大，300多兆。在公司的机器上安装的有点慢，晚上回家安装在自己的笔记本上速度就快多了。毕竟配置不能同日而语啊！</p>
<p>在这之前我一直没用过zend的产品，最多的有一次安装过一会zend studio for eclipse，但发现这个名字太长了，不喜欢就没再用了。然后我就一直用DW和UltraEdit，但是这两个对php的支持确实不咋的，所以最近使用起来也不是很方便。便想着用用这个新版本的zend studio吧，它毕竟是基于eclipse平台开发的，eclipse用起来还是很熟悉的（而且名字也不长）。</p>]]></description>
			<content:encoded><![CDATA[<p>前段时间zend网站老是给我发送zend studio 7的推荐下载的邮件（因为我注册过zend官网的原因吧），一直没有理会。前两天无事，便去下载了最新版的zend studio 7。下载时已经是正式版了，文件不大，300多兆。在公司的机器上安装的有点慢，晚上回家安装在自己的笔记本上速度就快多了。毕竟配置不能同日而语啊！</p>
<p>在这之前我一直没用过zend的产品，最多的有一次安装过一会zend studio for eclipse，但发现这个名字太长了，不喜欢就没再用了。然后我就一直用DW和UltraEdit，但是这两个对php的支持确实不咋的，所以最近使用起来也不是很方便。便想着用用这个新版本的zend studio吧，它毕竟是基于eclipse平台开发的，eclipse用起来还是很熟悉的（而且名字也不长）。</p>
<h3>Zend Studio 7官方宣传画：</h3>
<p>
<img src="http://static.zend.com/topics/studio7-release-product-main.jpg" class="aligncenter" alt="zend studio" /><br />
官方地址：<a href="http://www.zend.com/en/products/studio/" rel="external">http://www.zend.com/en/products/studio/</a>
</p>
<h3>新功能特性：</h3>
<p>1.Zend Studio 7.0 基于Eclipse 的最新版本构建(Galileo);</p>
<p>2.支持php5.3版本;</p>
<p>3.集成zend server调试服务器;</p>
<p>4.zend framework快速应用开发;</p>
<p>5.更强的源码编辑,更好的性能提升。</p>
<h3>下载地址：</h3>
<p>官方下载页面（下载需注册会员）：<a href="http://www.zend.com/en/products/studio/downloads" rel="external">http://www.zend.com/en/products/studio/downloads</a></p>
<p>VeryCD网站分享下载：<a href="http://www.verycd.com/topics/2760274/" rel="external">http://www.verycd.com/topics/2760274/</a></p>
<h3>序列号共享（貌似此序列号可以无限人使用）：</h3>
<p>
Username: zendstudio.net<br />
Serial Number: 3727234F6095F72034F6095F<br />
<img src="http://www.ihiro.org/blog/wp-content/uploads/2009/08/zend-studio-7-sn.jpg" alt="zend-studio-7-sn" title="zend-studio-7-sn" width="412" height="207" class="aligncenter size-full wp-image-456" /></p>
<h2  class="related_post_title">你也许会喜欢阅读这些：</h2><ul class="related_post"><li>2011年01月11日 -- <a href="http://www.ihiro.org/intellij-idea" title="软件:使用IntelliJ IDEA，高效前端开发">软件:使用IntelliJ IDEA，高效前端开发</a> (50)</li><li>2010年03月17日 -- <a href="http://www.ihiro.org/myeclipse-8-5-and-sn" title="软件:MyEclipse 8.5发布，附注册码">软件:MyEclipse 8.5发布，附注册码</a> (12)</li><li>2009年10月21日 -- <a href="http://www.ihiro.org/myeclipse-8-and-registration-number" title="软件:MyEclipse 8.0发布，附注册码">软件:MyEclipse 8.0发布，附注册码</a> (10)</li><li>2010年05月21日 -- <a href="http://www.ihiro.org/dw-html5-extension" title="扩展:Adobe放出Dreamweaver CS5 HTML 5扩展包">扩展:Adobe放出Dreamweaver CS5 HTML 5扩展包</a> (16)</li><li>2010年04月23日 -- <a href="http://www.ihiro.org/mindjet-mindmanager" title="软件:心智图法(Mindjet MindManager)，思维图制作">软件:心智图法(Mindjet MindManager)，思维图制作</a> (10)</li><li>2010年01月13日 -- <a href="http://www.ihiro.org/mozilla-software-series-email-calendar" title="软件:Mozilla软件系列之邮件、日历软件">软件:Mozilla软件系列之邮件、日历软件</a> (15)</li><li>2009年12月25日 -- <a href="http://www.ihiro.org/httpwatch-for-viewing-the-http-requests" title="软件:查看页面的http请求软件HttpWatch">软件:查看页面的http请求软件HttpWatch</a> (10)</li><li>2009年12月11日 -- <a href="http://www.ihiro.org/pathinfo-to-obtain-filepath-and-filename" title="PHP:pathinfo()获得文件的路径、名称等信息">PHP:pathinfo()获得文件的路径、名称等信息</a> (20)</li><li>2009年09月11日 -- <a href="http://www.ihiro.org/3d-action-adventure-game-mini-ninja" title="游戏:3D动作冒险类游戏《迷你忍者》">游戏:3D动作冒险类游戏《迷你忍者》</a> (10)</li><li>2009年08月20日 -- <a href="http://www.ihiro.org/array-sort-function" title="PHP:数组排序函数大总结">PHP:数组排序函数大总结</a> (6)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.ihiro.org/zend-studio-7/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
