<?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>代码收藏 &#187; 截取 itlearner</title> <atom:link href="http://code.9enjoy.com/tag/%e6%88%aa%e5%8f%96-itlearner/feed/" rel="self" type="application/rss+xml" /><link>http://code.9enjoy.com</link> <description>收集网站开发时常用到的代码(asp,php,js等)，以函数为主</description> <lastBuildDate>Mon, 24 Jan 2011 14:23:49 +0000</lastBuildDate> <generator>http://wordpress.org/?v=2.9.1</generator> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <item><title>getcon &#8211; 截取函数(itlearner原创)</title><link>http://code.9enjoy.com/php/getcon-%e6%88%aa%e5%8f%96%e5%87%bd%e6%95%b0itlearner%e5%8e%9f%e5%88%9b/</link> <comments>http://code.9enjoy.com/php/getcon-%e6%88%aa%e5%8f%96%e5%87%bd%e6%95%b0itlearner%e5%8e%9f%e5%88%9b/#comments</comments> <pubDate>Thu, 17 Apr 2008 11:08:01 +0000</pubDate> <dc:creator>enjoy</dc:creator> <category><![CDATA[php]]></category> <category><![CDATA[截取 itlearner]]></category><guid
isPermaLink="false">http://code.itlearner.com/?p=30</guid> <description><![CDATA[/*<br/>采集截取函数，主要用于分析采集的内容<br/>Author: hx<br/>getcon - 截取后去掉html字符，并去掉空格<br/>getcon2 - 单纯截取，直接返回截取内容。<br/>参数：<br/>$par可接受两种格式：<br/>1.前面字符{DATA}后面字符<br/>2.正则表达式<br/>*/
]]></description> <content:encoded><![CDATA[<p
class="code"><code>&lt;?php<br/>/*<br/>采集截取函数，主要用于分析采集的内容<br/>Author:&nbsp;itlearner<br/>getcon&nbsp;-&nbsp;截取后去掉html字符，并去掉空格<br/>getcon2&nbsp;-&nbsp;单纯截取，直接返回截取内容。<br/>参数：<br/>$par可接受两种格式：<br/>1.前面字符{DATA}后面字符<br/>2.正则表达式<br/>*/<br/><br/>function&nbsp;getcon($pat,$str){<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$title_var=explode("{DATA}",$pat);&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(count($title_var)&gt;1){&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$title_1=explode($title_var[0],$str);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$title_2=explode($title_var[1],$title_1[1]);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;strip_s(strip_tags($title_2[0]));<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}else{<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;preg_match_all($pat,$str,$res);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;strip_s(strip_tags($res[1][0]));<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br/>&nbsp;&nbsp;}<br/>&nbsp;&nbsp;<br/>function&nbsp;getcon2($pat,$str){<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$title_var=explode&nbsp;("{DATA}",$pat);&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(count($title_var)&gt;1){&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$title_1=explode($title_var[0],$str);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$title_2=explode($title_var[1],$title_1[1]);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;$title_2[0];<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}else{<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;preg_match_all($pat,$str,$res);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;$res[1][0];&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br/>&nbsp;&nbsp;}&nbsp;&nbsp;<br/>&nbsp;&nbsp;<br/>function&nbsp;strip_s($str){<br/>&nbsp;&nbsp;$str&nbsp;=&nbsp;preg_replace&nbsp;("/(\s+)/",&nbsp;'&nbsp;',&nbsp;$str);&nbsp;<br/>&nbsp;&nbsp;$str&nbsp;=&nbsp;str_replace(chr(13),'',$str);&nbsp;&nbsp;<br/>&nbsp;&nbsp;$str&nbsp;=&nbsp;str_replace(chr(10),'&lt;br&gt;',$str);&nbsp;&nbsp;<br/>&nbsp;&nbsp;$str&nbsp;=&nbsp;ltrim($str);<br/>&nbsp;&nbsp;$str&nbsp;=&nbsp;trim($str);<br/>&nbsp;&nbsp;return&nbsp;$str;&nbsp;&nbsp;<br/>&nbsp;&nbsp;}<br/>&nbsp;&nbsp;?&gt;</code></p> <img
src="http://code.9enjoy.com/?ak_action=api_record_view&id=30&type=feed" alt="" />]]></content:encoded> <wfw:commentRss>http://code.9enjoy.com/php/getcon-%e6%88%aa%e5%8f%96%e5%87%bd%e6%95%b0itlearner%e5%8e%9f%e5%88%9b/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk
Database Caching 8/14 queries in 0.004 seconds using disk

Served from: code.itlearner.com @ 2012-02-07 03:05:43 -->
