Home > php教程 > php手册 > body text

关键字break代码优化片段,

WBOY
Release: 2016-06-13 08:49:42
Original
1031 people have browsed it

关键字break代码优化片段,

 

 

       <span>$data</span>=<span>array</span><span>();
</span>       <span>//</span><span>循环页面</span>
       <span>foreach</span>(<span>$config_content</span>['pages'] <span>as</span> <span>$page_type_key</span>=><span>$page_type_val</span><span>){
</span>           <span>if</span>(<span>$page_type_val</span>['page_type']==<span>$page_type</span><span>){
</span>               <span>//</span><span>循环模块</span>
               <span>foreach</span>(<span>$config_content</span>['pages'][<span>$page_type_key</span>]['blocks'] <span>as</span> <span>$block_type_key</span>=><span>$block_type_val</span><span>){
</span>                   <span>if</span>(<span>$block_type_val</span>['blocktype']==<span>$blocktype</span><span>){</span>                       <br />              <span>foreach</span>(<span>$_POST</span> <span>as</span> <span>$key</span>=><span>$val</span><span>){
</span>                           <span>if</span>(<span>is_string</span>(<span>$val</span><span>)){
</span>                               <span>$data</span>[<span>$key</span>] = <span>trim</span>(<span>$val</span><span>);
</span>                           }<span>else</span><span>{
</span>                               <span>$data</span>[<span>$key</span>] = <span>$val</span><span>;
</span><span>                           }
</span><span>                       }
</span>                       <span>$config_content</span>['pages'][<span>$page_type_key</span>]['blocks'][<span>$block_type_key</span>]['settings']=<span>$data</span><span>;<br />              <span>break<span>;</span></span>//代码优化的地方,跳出内层的foreach循环
</span><span>                   }
               }
</span>               <span>break</span><span>;//代码优化的地方<span>,跳出外层的foreach循环</span>
</span><span>           }
       }</span>
Copy after login

 

   
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!