Home  >  Article  >  Backend Development  >  js数组跟php数组的区别

js数组跟php数组的区别

WBOY
WBOYOriginal
2016-06-13 12:16:591416browse

js数组和php数组的区别
var arr=new Array(c+1+f);  
for(var i=1;i {   Array[i]="";  } 
 for(var i=1;i {   if(i{    Array[i]+="第"+i+"天";   }  
 else  
 {    Array[i]+=“*”+"第"+i+"天";   }
 }
这段js这么改写成php?
新手,数组看了概念还是不通
------解决思路----------------------

$arr = array();<br />$c   = 10;<br />$f   = 5;<br />$d   = 7;<br /><br />for( $i = 1; $i <= ($c + $f) ; $i++){<br />    $arr[ $i ] = '';<br />}<br /><br />for( $i = 1; $i <= ($c + $f) ; $i++){<br />    if( $i <= $d ){<br />        $arr[$i] .= "第{$i}天";<br />    }else{<br />        $arr[$i] .= "*第{$i}天";<br />    }<br />}<br /><br />print_r($arr);

------解决思路----------------------
php的数组不是数组

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