首页  >  文章  >  php教程  >  关键字break代码优化片段,

关键字break代码优化片段,

WBOY
WBOY原创
2016-06-13 08:49:421033浏览

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

 

   
声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn