Home  >  Article  >  php教程  >  关键字break代码优化片段,

关键字break代码优化片段,

WBOY
WBOYOriginal
2016-06-13 08:49:421033browse

关键字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>

 

   
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