A. 在php中「以逗號分隔符將字元分割後存入數組」的函數是什麼
函數是$string = "1,2,3,4,5";$array = explode(",",$string); 之後就得出一個數組,$array(1,2,3,4,5);
Java 格式字元串中 『,』使用及說明:
1、Java API中解釋:public PrintStream printf(String format, Object... args)使用指定格式字元串和參數將格式化的字元串寫入此輸出流的便捷方法。
2、參數:format - 在格式字元串的語法中描述的格式字元串,args - 格式字元串中的格式說明符引用的參數。
3、重點:格式字元串的語法---標志 『,』 -- 結果將包括特定於語言環境的組分隔符
4、因為在Java API 中點擊組分隔符鏈接到了獲取千位分隔符的方法,所以的確可以理解成在
printf 方法中「,」 會在格式化輸出過程中輸出千位分隔符。
5、Java 中格式說明符可以通過相對索引引用參數。標志『<』,重用以前格式說明符的參數。也就是為什麼 %<f 會輸出 0.555000 的原因。
B. php 怎麼用逗號把一段混合字元串 隔開
$arr=explode(",",$str); //返回一個數組,包含被用逗號分割字元串之後的各個片段
C. php以逗號分割txt文件裡面的字元串問題
介紹兩個函數給你
<?php
//利用 explode 函數分割字元串到數組
$source = "hello1,hello2,hello3,hello4,hello5";//按逗號分離字元串
$hello = explode(',',$source);
for($index=0;$index<count($hello);$index++){
echo $hello[$index];echo "</br>";
}
?>
<?php
//split函數進行字元分割
// 分隔符可以是斜線,點,或橫線
$date = "04/30/1973";
list($month, $day, $year) = split ('[/.-]', $date);
echo "Month: $month; Day: $day; Year: $year<br />\n";
?>
D. PHP用逗號分隔的詞語,輸出時把分隔的詞語加上相應的鏈接
加上一個中間變數即可,如下:
<?php
function gettitles($tit) {
$hello = explode(',',"$tit");
$temp = '';
for($index=0;$index<count($hello);$index++){
$temp .= "<a href='/search/".$hello[$index]."'>".$hello[$index]."</a><br>";
}
return $temp;
}
echo gettitles("樹,離,黃昏");
?>
E. php查詢結果如何處理成逗號分割的數組
implode(",",$arr);//鏈接字元串,數組中間用逗號隔開
詳細字元串處理可以參考
http://www.tocus.com.cn/?send=article_show&id=86&class=2
F. php 如何用逗號把字元串分割為數組並把數組分別寫入資料庫
分割字元串可以用explode函數
$str="1,2,3,4,5,6";
$arr=explode(",",$str);
foreach($arras$a){
#插入資料庫就可以
}
G. php以逗號為分割,判斷是否為數組
$string = "1,2,3,4,5";
$array = explode(",",$string);
$string哪怕為只是1,經過explode(",",$string);處理後都數組了,數組值只是 array(1); 一個元素。
要判斷1,2,3與只有1的區別用count就可以
if(count($array) > 1){
//1,2,3
}elseif(count($array)==1){
//1
}else{
//空
}
H. php 如何把兩個字元串用逗號隔開存進資料庫的一個欄位中
用點連接符把兩個字元串連接起來,然後保存即可。
假設$a="abc";$b="def";
$c=$a.",".$b;
則,$c="abc,def";
3.然後按照正常的保存方式,保存到資料庫即可。
注意:這種方式,需要對a,b兩個字元串有一定的了解,比如,a,和b當中,都不能有作為分隔符的逗號,不然的話,如果將來再用逗號來分離的話,會有困難。
當然,也可以自定義分離符號。
I. php 數字怎樣用逗號分開
<?php
$aaa="123456";
$bbb=implode(',',str_split($aaa));
echo$bbb;
?>
J. php數組輸出的時候.用逗號分隔..
$array = array('0' => array('aa' => 'ss'), '1' => array('aa' => 'bb'));
$value = array();
foreach ($array as $var) {
$value[] = "'" . $var['aa'] . "'";
}
$because = 'where c_proce in (' . implode(',', $value) . ')';
echo $because;