关键字break代码优化片断

WBOY
Freigeben: 2016-06-13 12:27:55
Original
908 Leute haben es durchsucht

关键字break代码优化片段

 

 

       <span style="color: #800080;">$data</span>=<span style="color: #0000ff;">array</span><span style="color: #000000;">();</span>       <span style="color: #008000;">//</span><span style="color: #008000;">循环页面</span>       <span style="color: #0000ff;">foreach</span>(<span style="color: #800080;">$config_content</span>['pages'] <span style="color: #0000ff;">as</span> <span style="color: #800080;">$page_type_key</span>=><span style="color: #800080;">$page_type_val</span><span style="color: #000000;">){</span>           <span style="color: #0000ff;">if</span>(<span style="color: #800080;">$page_type_val</span>['page_type']==<span style="color: #800080;">$page_type</span><span style="color: #000000;">){</span>               <span style="color: #008000;">//</span><span style="color: #008000;">循环模块</span>               <span style="color: #0000ff;">foreach</span>(<span style="color: #800080;">$config_content</span>['pages'][<span style="color: #800080;">$page_type_key</span>]['blocks'] <span style="color: #0000ff;">as</span> <span style="color: #800080;">$block_type_key</span>=><span style="color: #800080;">$block_type_val</span><span style="color: #000000;">){</span>                   <span style="color: #0000ff;">if</span>(<span style="color: #800080;">$block_type_val</span>['blocktype']==<span style="color: #800080;">$blocktype</span><span style="color: #000000;">){</span>                       <br>              <span style="color: #0000ff;">foreach</span>(<span style="color: #800080;">$_POST</span> <span style="color: #0000ff;">as</span> <span style="color: #800080;">$key</span>=><span style="color: #800080;">$val</span><span style="color: #000000;">){</span>                           <span style="color: #0000ff;">if</span>(<span style="color: #008080;">is_string</span>(<span style="color: #800080;">$val</span><span style="color: #000000;">)){</span>                               <span style="color: #800080;">$data</span>[<span style="color: #800080;">$key</span>] = <span style="color: #008080;">trim</span>(<span style="color: #800080;">$val</span><span style="color: #000000;">);</span>                           }<span style="color: #0000ff;">else</span><span style="color: #000000;">{</span>                               <span style="color: #800080;">$data</span>[<span style="color: #800080;">$key</span>] = <span style="color: #800080;">$val</span><span style="color: #000000;">;</span><span style="color: #000000;">                           }</span><span style="color: #000000;">                       }</span>                       <span style="color: #800080;">$config_content</span>['pages'][<span style="color: #800080;">$page_type_key</span>]['blocks'][<span style="color: #800080;">$block_type_key</span>]['settings']=<span style="color: #800080;">$data</span><span style="color: #000000;">;<br>              <span style="color: #0000ff;">break<span style="color: #000000;">;</span></span>//代码优化的地方,跳出内层的foreach循环</span><span style="color: #000000;">                   }               }</span>               <span style="color: #0000ff;">break</span><span style="color: #000000;">;//代码优化的地方<span style="color: #000000;">,跳出外层的foreach循环</span></span><span style="color: #000000;">           }       }</span>
Nach dem Login kopieren

 

 
 
Verwandte Etiketten:
Quelle:php.cn
Erklärung dieser Website
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
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage