📄 function.unpack.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Unpack data from binary string</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.uniqid.html">uniqid</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.usleep.html">usleep</a></div> <div class="up"><a href="ref.misc.html">Misc. Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.unpack" class="refentry"> <div class="refnamediv"> <h1 class="refname">unpack</h1> <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">unpack</span> — <span class="dc-title">Unpack data from binary string</span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">array</span> <span class="methodname"><b><b>unpack</b></b></span> ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$format</tt></span> , <span class="methodparam"><span class="type">string</span> <tt class="parameter">$data</tt></span> )</div> <p class="para rdfs-comment"> Unpacks from a binary string into an array according to the given <i><tt class="parameter">format</tt></i>. </p> <p class="para"> <b>unpack()</b> works slightly different from Perl as the unpacked data is stored in an associative array. To accomplish this you have to name the different format codes and separate them by a slash /. </p> </div> <div class="refsect1 parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><i><tt class="parameter">format</tt></i></span> <dd> <p class="para"> See <a href="function.pack.html" class="function">pack()</a> for an explanation of the format codes. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">data</tt></i></span> <dd> <p class="para"> The packed data. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns an associative array containing unpacked elements of binary string. </p> </div> <div class="refsect1 examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example"> <p><b>Example #1 <b>unpack()</b> example</b></p> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br />$array </span><span style="color: #007700">= </span><span style="color: #0000BB">unpack</span><span style="color: #007700">(</span><span style="color: #DD0000">"c2chars/nint"</span><span style="color: #007700">, </span><span style="color: #0000BB">$binarydata</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> <div class="example-contents"><p> The resulting array will contain the entries "chars1", "chars2" and "int". </p></div> </div> </p> </div> <div class="refsect1 notes"> <h3 class="title">Notes</h3> <div class="caution"><b class="caution">Caution</b> <p class="para"> Note that PHP internally stores integral values as signed. If you unpack a large unsigned long and it is of the same size as PHP internally stored values the result will be a negative number even though unsigned unpacking was specified. </p> </div> </div> <div class="refsect1 seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"><a href="function.pack.html" class="function" rel="rdfs-seeAlso">pack()</a></li> </ul> </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.uniqid.html">uniqid</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.usleep.html">usleep</a></div> <div class="up"><a href="ref.misc.html">Misc. Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -