Heim  >  Artikel  >  php教程  >  关键字break代码优化片段,

关键字break代码优化片段,

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

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

 

   
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn