欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

asp函數(shù)split()對(duì)應(yīng)php函數(shù)explode()

 更新時(shí)間:2019年02月27日 14:16:04   作者:我是高手高手高高手  
今天小編就為大家分享一篇關(guān)于asp函數(shù)split()對(duì)應(yīng)php函數(shù)explode(),小編覺得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來看看吧
<?php
//利用 explode 函數(shù)分割字符串到數(shù)組
$source = "hello1,hello2,hello3,hello4,hello5";//按逗號(hào)分離字符串
$hello = explode(',',$source);
for($i=0;$i<count($hello);$i++){
echo $hello[$i];echo "</br>";
}
?>

截取去掉最后/第一個(gè)字符

$newstr = substr($str,0,strlen($str)-1); 

取得數(shù)組的具體數(shù)據(jù)

  $date = "04,30"; 
  list($month, $day) = split ('[,.-]', $date); 
  echo "Month: $month; Day: $day;<br />\n";

去除數(shù)組中重復(fù)的元素值 array_unique()

<meta charset="utf-8" />
<?php 
$a1="206,206,206,201,206,201";
//$array = explode(',', $a1); //字符串組成數(shù)組
$array1=implode(",",array_unique(explode(',', $a1)));
 print_r($array1);
?>

數(shù)組索引值如何重新從0開始遞增

<?php
  $a=array("a"=>"Cat","b"=>"Dog","c"=>"Horse");
  print_r(array_values($a));
  // 輸出:
  // Array ( [0] => Cat [1] => Dog [2] => Horse )
?>

統(tǒng)計(jì)數(shù)組元素個(gè)數(shù)

$a="303,304,305,306,307";
$a = explode(',',$a);
echo count($a);

JS split

<script language="javascript"> 
str="2,2,3,5,6,6"; //這是一字符串 
var strs= new Array(); //定義一數(shù)組 
strs=str.split(","); //字符分割 
for (i=0;i<strs.length ;i++ ) 
{ 
document.write(strs[i]+"<br/>"); //分割后的字符輸出 
} 
</script> 

explode() 函數(shù)把字符串分割為數(shù)組。

// 示例 1 $pizza = "piece1 piece2 piece3 piece4 piece5 piece6"; 
$pieces = explode(" ", $pizza); 
echo $pieces[0]; // piece1 
echo $pieces[1]; // piece2 

implode() 函數(shù)把數(shù)組元素組合為一個(gè)字符串。

$array = array('a' => 1, 'b'=>2, 'c'=>3, 'd'=>4);
$string = implode("-",$array)
echo $string;
//==== 結(jié)果就是:1-2-3-4;

總結(jié)

以上就是這篇文章的全部?jī)?nèi)容了,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,謝謝大家對(duì)腳本之家的支持。如果你想了解更多相關(guān)內(nèi)容請(qǐng)查看下面相關(guān)鏈接

相關(guān)文章

最新評(píng)論