Home  >  Article  >  Backend Development  >  Use pack to fill in blanks unpack solution

Use pack to fill in blanks unpack solution

巴扎黑
巴扎黑Original
2016-11-10 11:40:051498browse

Java code

<?php  
$book = array(array(&#39;Elmer Gantry&#39;, &#39;Sinclair Lewis&#39;, 1927),  
              array(&#39;The Scarlatti Inheritance&#39;, &#39;Robert Ludlum&#39;, &#39;1971&#39;),  
              array(&#39;The Parsifal Mosaic&#39;, &#39;William Styron&#39;, &#39;1979&#39;));  
$i = 0;  
foreach($book as $bookline){  
        $var[$i] = pack(&#39;A25A14A4&#39;, $bookline[0], $bookline[1], $bookline[2]);  
        $i++;  
}  
  
print_r ($var);  
  
for($i=0;$i<count($var); $i++){  
        $var[$i] = unpack(&#39;A25tit/A14aut/A4year&#39;, $var[$i]);  
}  
  
print_r ($var);  
echo $var[1][&#39;tit&#39;];  
?>


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn