关键字break代码优化片段,_PHP教程

WBOY
Libérer: 2016-07-12 09:03:21
original
1031 Les gens l'ont consulté

关键字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>
Copier après la connexion

 

   

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1081560.htmlTechArticle关键字break代码优化片段, $data = array (); // 循环页面 foreach ( $config_content ['pages'] as $page_type_key = $page_type_val ){ if ( $page_type_val ['page_type']==...
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal