<?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>Web Development Notes &#187; array</title>
	<atom:link href="http://blog.eood.cn/tag/array/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.eood.cn</link>
	<description>PHP, Drupal, Erlang, MySQL, Java, MongoDB, Linux, vim, ssh, screen etc</description>
	<lastBuildDate>Sat, 31 Dec 2011 12:49:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>how to apply pager to an array in drupal</title>
		<link>http://blog.eood.cn/how-to-apply-pager-to-an-array-in-drupal</link>
		<comments>http://blog.eood.cn/how-to-apply-pager-to-an-array-in-drupal#comments</comments>
		<pubDate>Thu, 22 Oct 2009 02:10:06 +0000</pubDate>
		<dc:creator>Bruce Dou</dc:creator>
				<category><![CDATA[Life & Work]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[Drupal]]></category>
		<category><![CDATA[pager]]></category>

		<guid isPermaLink="false">http://blog.eood.cn/articles/340</guid>
		<description><![CDATA[add this function function pager_array($array, $limit = 20, $element = 0) { global $pager_page_array, $pager_total, $pager_total_items; $page = isset($_GET['page']) ? $_GET['page'] : &#8221;; $pager_page_array = explode(&#8216;,&#8217;, $page); $pager_total_items[$element] = count($array); $pager_total[$element] = ceil($pager_total_items[$element] / $limit); $pager_page_array[$element] = max(0, min((int)$pager_page_array[$element], ((int)$pager_total[$element]) &#8211; 1)); return array_splice($array,$pager_page_array[$element]*$limit,$limit); } how to use // this was filled with all elements, [...]]]></description>
			<content:encoded><![CDATA[<p>add this function</p>
<p>   function pager_array($array, $limit = 20, $element = 0) {<br />
     global $pager_page_array, $pager_total, $pager_total_items;<br />
     $page = isset($_GET['page']) ? $_GET['page'] : &#8221;;  </p>
<p>     $pager_page_array = explode(&#8216;,&#8217;, $page);  </p>
<p>     $pager_total_items[$element] = count($array);<br />
     $pager_total[$element] = ceil($pager_total_items[$element] / $limit);<br />
     $pager_page_array[$element] = max(0,  min((int)$pager_page_array[$element], ((int)$pager_total[$element]) &#8211; 1));<br />
     return array_splice($array,$pager_page_array[$element]*$limit,$limit);<br />
   } </p>
<p>how to use<br />
    // this was filled with all elements, and pager_array simply makes the array only have the elements that are to be displayed on the page.<br />
    $files = pager_array($files);<br />
    foreach($files as $f)<br />
      echo &#8220;<img src='".url("$_GET[il_d]/$f")."' alt='' /><br />\n&#8221;;<br />
      echo theme(&#8216;pager&#8217;); // prints out the indexes for browsing to the next page and everything.  </p>
<p> some urls about ajax in drupal:</p>
<p>http://11heavens.com/using-ajax-in-Drupal-6</p>
<p>http://www.drupaleye.com/node/26</p>
<p>http://drupal.org/node/42562</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.eood.cn/how-to-apply-pager-to-an-array-in-drupal/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP, 2维数组如何排序</title>
		<link>http://blog.eood.cn/php%2c2%e7%bb%b4%e6%95%b0%e7%bb%84%e5%a6%82%e4%bd%95%e6%8e%92%e5%ba%8f</link>
		<comments>http://blog.eood.cn/php%2c2%e7%bb%b4%e6%95%b0%e7%bb%84%e5%a6%82%e4%bd%95%e6%8e%92%e5%ba%8f#comments</comments>
		<pubDate>Wed, 14 Oct 2009 18:08:29 +0000</pubDate>
		<dc:creator>Bruce Dou</dc:creator>
				<category><![CDATA[Life & Work]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[sort]]></category>

		<guid isPermaLink="false">http://blog.eood.cn/articles/333</guid>
		<description><![CDATA[function orderBy(&#38;$data, $field) { $code = &#8220;return strnatcmp(\$a['$field'], \$b['$field']);&#8221;; usort($data, create_function(&#8216;$a,$b&#8217;, $code)); } orderBy($data, &#8216;age&#8217;); http://www.the-art-of-web.com/php/sortarray/ ﻿]]></description>
			<content:encoded><![CDATA[<p>function orderBy(&amp;$data, $field)<br />
{<br />
$code = &#8220;return strnatcmp(\$a['$field'], \$b['$field']);&#8221;;<br />
usort($data, create_function(&#8216;$a,$b&#8217;, $code));<br />
}</p>
<p>orderBy($data, &#8216;age&#8217;);</p>
<p>http://www.the-art-of-web.com/php/sortarray/</p>
<p>﻿</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.eood.cn/php%2c2%e7%bb%b4%e6%95%b0%e7%bb%84%e5%a6%82%e4%bd%95%e6%8e%92%e5%ba%8f/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 0.079 seconds. -->
<!-- File not cached! Super Cache Couldn't write to: wp-content/cache/wp-cache-9b86fa698d777713689c3d4536ebe991.html -->

