Re: [請益] 又來問問題了Orz 將文字方塊的值存入ar …
※ 引述《dichia (ptt處處有溫情)》之銘言:
: ※ 引述《dinos (守護神)》之銘言:
: : returns an array containing all the values of array1 that are not present in
: : any of the other arguments.
: : 也就是比對 array1 而已
: : 試試這樣就知道了
: : <?php
: : $array1 = array("a" => "green", "b" => "brown", "c" => "blue", "red");
: : $array2 = array("a" => "green", "red");
: : $array3 = array("brown");
: : $array4 = array("c" => "blue");
: : $result = array_diff_assoc($array1, $array2,$array3,$array4);
: : print_r($result);
: 這行是會把結果輸出為Array ( [b] => brown )
: 有沒有別的輸出指令只取[b] => brown或是brown?
: 我試過用echo $result 結果變成只有Array =.=
<?php
echo $result['b'];
?>
或
<?php
foreach($result as $result_key => $result_value) {
echo $result_key . "=>" .$relust_value ."<br />";
}
?>
: : ?>
: 我第一篇的文章只剩該怎麼把輸入文字方塊的數值存成array了
: 麻煩知道的高手指點一下 謝謝!
form elements 的 name 最好用 /^\a\w+$/ 的命名方式
例如
<input type="text" name="item1" />
<input type="text" name="item2" />
<input type="text" name="item3" />
<input type="text" name="item4" />
===
<?php
$item_count=1;
while(!empty($_POST['item'.$item_count])) {
$item_array[]=$_POST['item'.$item_count];
$item_count++;
}
?>
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.113.158.10
※ 編輯: dinos 來自: 140.113.158.10 (11/26 19:55)
討論串 (同標題文章)
PHP 近期熱門文章
PTT數位生活區 即時熱門文章
63
151