<?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>Ruben Sargsyan &#187; sort</title>
	<atom:link href="http://rubensargsyan.com/tag/sort/feed/" rel="self" type="application/rss+xml" />
	<link>http://rubensargsyan.com</link>
	<description>Personal Website</description>
	<lastBuildDate>Thu, 01 Dec 2011 19:15:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Retrieve links and sort them by follow or nofollow</title>
		<link>http://rubensargsyan.com/retrieve-links-and-sort-them-by-follow-or-nofollow/</link>
		<comments>http://rubensargsyan.com/retrieve-links-and-sort-them-by-follow-or-nofollow/#comments</comments>
		<pubDate>Tue, 16 Nov 2010 11:50:14 +0000</pubDate>
		<dc:creator>Ruben Sargsyan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[follow links]]></category>
		<category><![CDATA[links]]></category>
		<category><![CDATA[nofollow links]]></category>
		<category><![CDATA[sort]]></category>

		<guid isPermaLink="false">http://rubensargsyan.com/?p=475</guid>
		<description><![CDATA[This PHP example is used to retrieve all links from a file content or a url content, then sort by the follow links or nofollow links and show them: &#60;?php $file = &#34;http://example.com&#34;; &#160; $content = file_get_contents&#40;$file&#41;; $links = array&#40;&#34;follow&#34;=&#62;array&#40;&#41;,&#34;nofollow&#34;=&#62;array&#40;&#41;&#41;; &#160; preg_match_all&#40;&#34;/(&#60;a.*&#62;)(.*)(&#60;\/a&#62;)/ismU&#34;,$content,$matches,PREG_SET_ORDER&#41;; &#160; if&#40;empty&#40;$matches&#41;&#41;&#123; echo&#40;&#34;There is no link in the file &#34;.$file.&#34;.&#34;&#41;; &#125;else&#123; foreach&#40;$matches as [...]]]></description>
			<content:encoded><![CDATA[<p>This PHP example is used to retrieve all links from a file content or a url content, then sort by the follow links or nofollow links and show them<span id="more-475"></span>:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;http://example.com&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #990000;">file_get_contents</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$links</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;follow&quot;</span><span style="color: #339933;">=&gt;</span>array<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;nofollow&quot;</span><span style="color: #339933;">=&gt;</span>array<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">preg_match_all</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/(&lt;a.*&gt;)(.*)(&lt;\/a&gt;)/ismU&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$content</span><span style="color: #339933;">,</span><span style="color: #000088;">$matches</span><span style="color: #339933;">,</span>PREG_SET_ORDER<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$matches</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;There is no link in the file &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$file</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;.&quot;</span><span style="color: #009900;">&#41;</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;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$matches</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$match</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/href\s*=\s*[\'|<span style="color: #000099; font-weight: bold;">\&quot;</span>]\s*([^<span style="color: #000099; font-weight: bold;">\&quot;</span>|\']*)\s*[\'|<span style="color: #000099; font-weight: bold;">\&quot;</span>]/i&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$match</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #000088;">$href</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/rel\s*=\s*[\'|<span style="color: #000099; font-weight: bold;">\&quot;</span>]\s*nofollow\s*[\'|<span style="color: #000099; font-weight: bold;">\&quot;</span>]/i&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$match</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$links</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;nofollow&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$href</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</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: #000088;">$links</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;follow&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$href</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000088;">$output</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;h1&gt;Nofollow links&lt;/h1&gt;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$links</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;nofollow&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;There is no nofollow link.&quot;</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: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;ol type='1'&gt;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$links</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;nofollow&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$link</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;li&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$link</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/li&gt;&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;/ol&gt;&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;h1&gt;Follow links&lt;/h1&gt;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$links</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;follow&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;There is no follow link.&quot;</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: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;ol type='1'&gt;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$links</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;follow&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$link</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;li&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$link</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/li&gt;&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;/ol&gt;&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #b1b100;">echo</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$output</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://rubensargsyan.com/retrieve-links-and-sort-them-by-follow-or-nofollow/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Sort all words and write into a file</title>
		<link>http://rubensargsyan.com/sort-all-words-and-write-into-a-file/</link>
		<comments>http://rubensargsyan.com/sort-all-words-and-write-into-a-file/#comments</comments>
		<pubDate>Mon, 04 Oct 2010 07:03:40 +0000</pubDate>
		<dc:creator>Ruben Sargsyan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[sort]]></category>
		<category><![CDATA[text]]></category>
		<category><![CDATA[words]]></category>

		<guid isPermaLink="false">http://rubensargsyan.com/?p=410</guid>
		<description><![CDATA[A PHP example to sort all words of a text in alphabetical order and write the words into a file. &#60;?php function sort_all_words_and_write_into_file&#40;$text,$file&#41;&#123; preg_match_all&#40;&#34;/[a-z0-9_\-]+/i&#34;,$text,$matches,PREG_PATTERN_ORDER&#41;; &#160; $matches = array_unique&#40;$matches&#91;0&#93;&#41;; &#160; natcasesort&#40;$matches&#41;; &#160; $file_content = &#34;&#34;; &#160; while&#40;current&#40;$matches&#41;&#41;&#123; $file_content .= current&#40;$matches&#41;; &#160; if&#40;next&#40;$matches&#41;&#41;&#123; $file_content .= &#34;\r\n&#34;; &#125; &#125; &#160; if&#40;file_exists&#40;$file&#41;&#41;&#123; if&#40;is_writable&#40;$file&#41;&#41;&#123; if&#40;file_put_contents&#40;$file,$file_content&#41;&#41;&#123; return true; &#125; &#125; &#125;else&#123; [...]]]></description>
			<content:encoded><![CDATA[<p>A PHP example to sort all words of a text in alphabetical order and write the words into a file<span id="more-410"></span>.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">function</span> sort_all_words_and_write_into_file<span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #339933;">,</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #990000;">preg_match_all</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/[a-z0-9_\-]+/i&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$text</span><span style="color: #339933;">,</span><span style="color: #000088;">$matches</span><span style="color: #339933;">,</span>PREG_PATTERN_ORDER<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$matches</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_unique</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$matches</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: #339933;">;</span>
&nbsp;
    <span style="color: #990000;">natcasesort</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$matches</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$file_content</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">current</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$matches</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$file_content</span> <span style="color: #339933;">.=</span> <span style="color: #990000;">current</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$matches</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">next</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$matches</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$file_content</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">file_exists</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</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: #990000;">is_writable</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</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: #990000;">file_put_contents</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #339933;">,</span><span style="color: #000088;">$file_content</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">file_put_contents</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #339933;">,</span><span style="color: #000088;">$file_content</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$text</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;A PHP example to sort all words of a text in alphabetical order and write the words into a file.&quot;</span><span style="color: #339933;">;</span>
&nbsp;
sort_all_words_and_write_into_file<span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;file.txt&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>The function returns false if the words haven&#8217;t been written into the file.</p>
]]></content:encoded>
			<wfw:commentRss>http://rubensargsyan.com/sort-all-words-and-write-into-a-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sort texts by matching the word</title>
		<link>http://rubensargsyan.com/sort-texts-by-matching-the-word/</link>
		<comments>http://rubensargsyan.com/sort-texts-by-matching-the-word/#comments</comments>
		<pubDate>Mon, 15 Feb 2010 12:01:04 +0000</pubDate>
		<dc:creator>Ruben Sargsyan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[matching]]></category>
		<category><![CDATA[sort]]></category>
		<category><![CDATA[texts]]></category>

		<guid isPermaLink="false">http://rubensargsyan.com/?p=274</guid>
		<description><![CDATA[An example for sorting texts in array by matching the word in them: &#60;?php $word = &#34;plugin&#34;; &#160; function sort_by_matching_word&#40;$text1,$text2&#41;&#123; global $word; &#160; $text1_matched_words_count = preg_match&#40;&#34;/\b&#34;.$word.&#34;\b/i&#34;,$text1&#41;; $text2_matched_words_count = preg_match&#40;&#34;/\b&#34;.$word.&#34;\b/i&#34;,$text2&#41;; &#160; if&#40;$text1_matched_words_count&#60;$text2_matched_words_count&#41;&#123; return 1; &#125;elseif&#40;$text1_matched_words_count==$text2_matched_words_count&#41;&#123; return 0; &#125;else&#123; return -1; &#125; &#125; &#160; $wordpress_plugin_running_line = &#34;If you would like to have your running line on your [...]]]></description>
			<content:encoded><![CDATA[<p>An example for sorting texts in array by matching the word in them:<span id="more-274"></span></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$word</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;plugin&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> sort_by_matching_word<span style="color: #009900;">&#40;</span><span style="color: #000088;">$text1</span><span style="color: #339933;">,</span><span style="color: #000088;">$text2</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$word</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000088;">$text1_matched_words_count</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/\b&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$word</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;\b/i&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$text1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$text2_matched_words_count</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/\b&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$word</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;\b/i&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$text2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$text1_matched_words_count</span><span style="color: #339933;">&lt;</span><span style="color: #000088;">$text2_matched_words_count</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: #009900;">&#125;</span><span style="color: #b1b100;">elseif</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$text1_matched_words_count</span><span style="color: #339933;">==</span><span style="color: #000088;">$text2_matched_words_count</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;">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: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$wordpress_plugin_running_line</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;If you would like to have your running line on your Wordpress blog, so this plugin is just for you! It gives you the possibility to show one of the posts from your chosen category by the running line. So download and enjoy!&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$wordpress_plugin_explanatory_dictionary</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;This plugin is used when there are words, words expressions or sentences to be explained in the posts or pages of your wordpress blog. This plugin will help the visitors to read the explanations of the words (words expressions,sentences) you need via tooltips.&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$wordpress_plugin_greetings</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Any occasion to receive greetings? So, this plugin is just for you! This Widget plugin shows a greeting image which would be uploaded for the occasion and a pop up form for receiving the greetings. It is possible to show the greetings in any post or page.&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$my_plugins</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$wordpress_plugin_running_line</span><span style="color: #339933;">,</span><span style="color: #000088;">$wordpress_plugin_explanatory_dictionary</span><span style="color: #339933;">,</span><span style="color: #000088;">$wordpress_plugin_greetings</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">usort</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$my_plugins</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'sort_by_matching_word'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$my_plugins</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$my_plugin</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;p&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$my_plugin</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/p&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://rubensargsyan.com/sort-texts-by-matching-the-word/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

