Sophie

Sophie

distrib > Mageia > 4 > i586 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 1181

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Set collation strength</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="collator.setattribute.html">Collator::setAttribute</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="collator.sortwithsortkeys.html">Collator::sortWithSortKeys</a></div>
 <div class="up"><a href="class.collator.html">Collator</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="collator.setstrength" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Collator::setStrength</h1>
  <h1 class="refname">collator_set_strength</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.3.0, PECL intl &gt;= 1.0.0)</p><p class="refpurpose"><span class="refname">Collator::setStrength</span> -- <span class="refname">collator_set_strength</span> &mdash; <span class="dc-title">Set collation strength</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-collator.setstrength-description">
  <h3 class="title">Description</h3>
  <p class="para">
   Object oriented style
  </p>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">bool</span>
    <span class="methodname"><strong>Collator::setStrength</strong></span>
    ( <span class="methodparam"><span class="type">int</span> <code class="parameter">$strength</code></span>
   )</div>

  <p class="para rdfs-comment">
   Procedural style
  </p>
  <div class="methodsynopsis dc-description">
   <span class="type">bool</span>
    <span class="methodname"><strong>collator_set_strength</strong></span>
    ( <span class="methodparam"><span class="type"><a href="class.collator.html" class="type Collator">Collator</a></span> <code class="parameter">$coll</code></span>
   , <span class="methodparam"><span class="type">int</span> <code class="parameter">$strength</code></span>
   )</div>

  <p class="para rdfs-comment">
   The
   <a href="http://www.icu-project.org/" class="link external">&raquo;&nbsp;ICU</a>
   Collation Service supports many levels of comparison (named &quot;Levels&quot;, but
   also known as &quot;Strengths&quot;). Having these categories enables ICU to sort
   strings precisely according to local conventions. However, by allowing the
   levels to be selectively employed, searching for a string in text can be
   performed with various matching conditions.
  </p>
  <p class="para">
   <ol type="1">
    <li class="listitem">
     <p class="para"> 
      <em class="emphasis"> Primary Level</em>:
      Typically, this is used to denote differences between base characters
      (for example, &quot;a&quot; &lt; &quot;b&quot;). It is the strongest difference. For
      example, dictionaries are divided into different sections by base
      character. This is also called the level1 strength.
     </p>
    </li>
    <li class="listitem">
     <p class="para"> 
      <em class="emphasis"> Secondary Level</em>:
      Accents in the characters are considered secondary differences (for
      example, &quot;as&quot; &lt; &quot;às&quot; &lt; &quot;at&quot;). Other differences between letters
      can also be considered secondary differences, depending on the language.
      A secondary difference is ignored when there is a primary difference
      anywhere in the strings. This is also called the level2 strength.
      <blockquote class="note"><p><strong class="note">Note</strong>: 
       <p class="para">
        Note: In some languages (such as Danish), certain accented letters are
        considered to be separate base characters. In most languages, however,
        an accented letter only has a secondary difference from the unaccented
        version of that letter.
       </p>
      </p></blockquote>
     </p>
    </li>
    <li class="listitem">
     <p class="para"> 
      <em class="emphasis"> Tertiary Level</em>:
      Upper and lower case differences in characters are distinguished at
      the tertiary level (for example, &quot;ao&quot; &lt; &quot;Ao&quot; &lt; &quot;aò&quot;). In addition,
      a variant of a letter differs from the base form on the tertiary level
      (such as &quot;A&quot; and &quot; &quot;). Another example is the difference between large
      and small Kana. A tertiary difference is ignored when there is a primary
      or secondary difference anywhere in the strings. This is also called the
      level3 strength.
     </p>
    </li>
    <li class="listitem">
     <p class="para"> 
      <em class="emphasis"> Quaternary Level</em>:
      When punctuation is ignored (see Ignoring Punctuations ) at level 13,
      an additional level can be used to distinguish words with and without
      punctuation (for example, &quot;ab&quot; &lt; &quot;a-b&quot; &lt; &quot;aB&quot;). This difference is
      ignored when there is a primary, secondary or tertiary difference. This
      is also known as the level4 strength. The quaternary level should only
      be used if ignoring punctuation is required or when processing Japanese
      text (see Hiragana processing).
     </p>
    </li>
    <li class="listitem">
     <p class="para"> 
      <em class="emphasis"> Identical Level</em>:
      When all other levels are equal, the identical level is used as a
      tiebreaker. The Unicode code point values of the NFD form of each string
      are compared at this level, just in case there is no difference at
      levels 14. For example, Hebrew cantillation marks are only distinguished
      at this level. This level should be used sparingly, as only code point
      values differences between two strings is an extremely rare occurrence.
      Using this level substantially decreases the performance for both
      incremental comparison and sort key generation (as well as increasing
      the sort key length). It is also known as level 5 strength.
     </p>
    </li>
   </ol>
  </p>
  <p class="para">
   For example, people may choose to ignore accents or ignore accents and case
   when searching for text. Almost all characters are distinguished by the
   first three levels, and in most locales the default value is thus Tertiary.
   However, if Alternate is set to be Shifted, then the Quaternary strength
   can be used to break ties among whitespace, punctuation, and symbols that
   would otherwise be ignored. If very fine distinctions among characters are
   required, then the Identical strength can be used (for example, Identical
   Strength distinguishes between the Mathematical Bold Small A and the
   Mathematical Italic Small A.). However, using levels higher than Tertiary
   the Identical strength result in significantly longer sort keys, and slower
   string comparison performance for equal strings.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-collator.setstrength-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>

    <dt>

     <span class="term"><em><code class="parameter">coll</code></em></span>
     <dd>

      <p class="para">
       <a href="class.collator.html" class="classname">Collator</a> object.
      </p>
     </dd>

    </dt>

    <dt>

     <span class="term"><em><code class="parameter">strength</code></em></span>
     <dd>

      <p class="para">Strength to set.</p>
      <p class="para">
       Possible values are:
       <ul class="itemizedlist">
        <li class="listitem">
         <p class="para">
          <strong><code>Collator::PRIMARY</code></strong>
         </p>
        </li>
        <li class="listitem">
         <p class="para">
          <strong><code>Collator::SECONDARY</code></strong>
         </p>
        </li>
        <li class="listitem">
         <p class="para">
          <strong><code>Collator::TERTIARY</code></strong>
         </p>
        </li>
        <li class="listitem">
         <p class="para">
          <strong><code>Collator::QUATERNARY</code></strong>
         </p>
        </li>
        <li class="listitem">
         <p class="para">
          <strong><code>Collator::IDENTICAL</code></strong>
         </p>
        </li>
        <li class="listitem">
         <p class="para">
          <strong><code>Collator::DEFAULT_STRENGTH</code></strong>
         </p>
        </li>
       </ul>
      </p>
     </dd>

    </dt>

   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-collator.setstrength-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns <strong><code>TRUE</code></strong> on success or <strong><code>FALSE</code></strong> on failure.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-collator.setstrength-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-2499">
    <p><strong>Example #1  <span class="function"><strong>collator_set_strength()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$arr&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;array(&nbsp;</span><span style="color: #DD0000">'aò'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'Ao'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'ao'&nbsp;</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$coll&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">collator_create</span><span style="color: #007700">(&nbsp;</span><span style="color: #DD0000">'en_US'&nbsp;</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;Sort&nbsp;array&nbsp;using&nbsp;default&nbsp;strength.<br /></span><span style="color: #0000BB">collator_sort</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">$coll</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$arr&nbsp;</span><span style="color: #007700">);&nbsp;<br /></span><span style="color: #0000BB">var_export</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">$arr&nbsp;</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;Sort&nbsp;array&nbsp;using&nbsp;primary&nbsp;strength.<br /></span><span style="color: #0000BB">collator_set_strength</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">$coll</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">Collator</span><span style="color: #007700">::</span><span style="color: #0000BB">PRIMARY&nbsp;</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">collator_sort</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">$coll</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$arr&nbsp;</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_export</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">$arr&nbsp;</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>The above example will output:</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
array (
  0 =&gt; &#039;ao&#039;,
  1 =&gt; &#039;Ao&#039;,
  2 =&gt; &#039;aò&#039;,
)
array (
  0 =&gt; &#039;aò&#039;,
  1 =&gt; &#039;Ao&#039;,
  2 =&gt; &#039;ao&#039;,
)
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-collator.setstrength-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><a href="class.collator.html#intl.collator-constants" class="link"><a href="class.collator.html" class="classname">Collator</a> constants</a></li>
    <li class="member"> <span class="function"><a href="collator.getstrength.html" class="function" rel="rdfs-seeAlso">collator_get_strength()</a> - Get current collation strength</span></li>
   </ul>
  </p>
 </div>

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="collator.setattribute.html">Collator::setAttribute</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="collator.sortwithsortkeys.html">Collator::sortWithSortKeys</a></div>
 <div class="up"><a href="class.collator.html">Collator</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>