<!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>This factory method creates a hash from a string</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="quickhashstringinthash.loadfromfile.html">QuickHashStringIntHash::loadFromFile</a></div> <div class="next" style="text-align: right; float: right;"><a href="quickhashstringinthash.savetofile.html">QuickHashStringIntHash::saveToFile</a></div> <div class="up"><a href="class.quickhashstringinthash.html">QuickHashStringIntHash</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="quickhashstringinthash.loadfromstring" class="refentry"> <div class="refnamediv"> <h1 class="refname">QuickHashStringIntHash::loadFromString</h1> <p class="verinfo">(No version information available, might only be in SVN)</p><p class="refpurpose"><span class="refname">QuickHashStringIntHash::loadFromString</span> — <span class="dc-title">This factory method creates a hash from a string</span></p> </div> <div class="refsect1 description" id="refsect1-quickhashstringinthash.loadfromstring-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="modifier">static</span> <span class="type"><a href="class.quickhashstringinthash.html" class="type QuickHashStringIntHash">QuickHashStringIntHash</a></span> <span class="methodname"><strong>QuickHashStringIntHash::loadFromString</strong></span> ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$contents</code></span> [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$size</code><span class="initializer"> = 0</span></span> [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$options</code><span class="initializer"> = 0</span></span> ]] )</div> <p class="para rdfs-comment"> This factory method creates a new hash from a definition in a string. The format is the same as the one used in "loadFromFile". </p> </div> <div class="refsect1 parameters" id="refsect1-quickhashstringinthash.loadfromstring-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">contents</code></em></span> <dd> <p class="para"> The string containing a serialized format of the hash. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">size</code></em></span> <dd> <p class="para"> The amount of bucket lists to configure. The number you pass in will be automatically rounded up to the next power of two. It is also automatically limited from 4 to 4194304. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">options</code></em></span> <dd> <p class="para"> The same options that the class' constructor takes; except that the size option is ignored. It is automatically calculated to be the same as the number of entries in the hash, rounded up to the nearest power of two with a maximum limit of 4194304. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-quickhashstringinthash.loadfromstring-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns a new QuickHashStringIntHash. </p> </div> <div class="refsect1 examples" id="refsect1-quickhashstringinthash.loadfromstring-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-5160"> <p><strong>Example #1 <span class="function"><strong>QuickHashStringIntHash::loadFromString()</strong></span> example</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br />$contents </span><span style="color: #007700">= </span><span style="color: #0000BB">file_get_contents</span><span style="color: #007700">( </span><span style="color: #0000BB">dirname</span><span style="color: #007700">( </span><span style="color: #0000BB">__FILE__ </span><span style="color: #007700">) . </span><span style="color: #DD0000">"/simple.hash.string" </span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$hash </span><span style="color: #007700">= </span><span style="color: #0000BB">QuickHashStringIntHash</span><span style="color: #007700">::</span><span style="color: #0000BB">loadFromString</span><span style="color: #007700">(<br /> </span><span style="color: #0000BB">$contents</span><span style="color: #007700">,<br /> </span><span style="color: #0000BB">QuickHashStringIntHash</span><span style="color: #007700">::</span><span style="color: #0000BB">DO_NOT_USE_ZEND_ALLOC<br /></span><span style="color: #007700">);<br />foreach( </span><span style="color: #0000BB">range</span><span style="color: #007700">( </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">0x0f </span><span style="color: #007700">) as </span><span style="color: #0000BB">$key </span><span style="color: #007700">)<br />{<br /> </span><span style="color: #0000BB">$i </span><span style="color: #007700">= </span><span style="color: #0000BB">48712 </span><span style="color: #007700">+ </span><span style="color: #0000BB">$key </span><span style="color: #007700">* </span><span style="color: #0000BB">1631</span><span style="color: #007700">;<br /> </span><span style="color: #0000BB">$k </span><span style="color: #007700">= </span><span style="color: #0000BB">base_convert</span><span style="color: #007700">( </span><span style="color: #0000BB">$i</span><span style="color: #007700">, </span><span style="color: #0000BB">10</span><span style="color: #007700">, </span><span style="color: #0000BB">36 </span><span style="color: #007700">);<br /> echo </span><span style="color: #0000BB">$k</span><span style="color: #007700">, </span><span style="color: #DD0000">' => '</span><span style="color: #007700">, </span><span style="color: #0000BB">$hash</span><span style="color: #007700">-></span><span style="color: #0000BB">get</span><span style="color: #007700">( </span><span style="color: #0000BB">$k </span><span style="color: #007700">), </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> <div class="example-contents"><p>The above example will output something similar to:</p></div> <div class="example-contents screen"> <div class="cdata"><pre> 11l4 => 48712 12uf => 50343 143q => 51974 15d1 => 53605 16mc => 55236 17vn => 56867 194y => 58498 1ae9 => 60129 1bnk => 61760 1cwv => 63391 1e66 => 65022 1ffh => 66653 1gos => 68284 1hy3 => 69915 1j7e => 71546 1kgp => 73177 </pre></div> </div> </div> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="quickhashstringinthash.loadfromfile.html">QuickHashStringIntHash::loadFromFile</a></div> <div class="next" style="text-align: right; float: right;"><a href="quickhashstringinthash.savetofile.html">QuickHashStringIntHash::saveToFile</a></div> <div class="up"><a href="class.quickhashstringinthash.html">QuickHashStringIntHash</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>