[英]How To Insert Value From Textarea To Database With “|” Characters?
我的表tapphim有tap列, 鏈接列和播放器列
我想在“|”之前插入數據 並在“|”之后 在不同的列上,例如我將此值輸入到textarea:
1|fuuka-vietsub|https://drive.google.com/file/d/1tDKPbZ_gaNZrcYHt-tQtcF-TH0hMzGFi/view?usp=sharing
將1插入列點擊 , fuuka-vietsub插入列鏈接和https://drive.google.com/file/d/1tDKPbZ_gaNZrcYHt-tQtcF-TH0hMzGFi/view?usp=sharing to column player
我有來自index.php的代碼:
<form action="api.php" method="post">
<textarea name="themphim" id="themphim"></textarea>
<input type="submit" name="save" value="save"></input>
</form>
文件api.php:
<?php
include("db_connect.php");
if(isset($_POST['save']))
{
// Please give for me code
...
//
}
?>
謝謝大家 !
您可以使用explode
來分解使用分隔符
$string = '1|fuuka-vietsub|https://drive.google.com/file/d/1tDKPbZ_gaNZrcYHt-tQtcF-TH0hMzGFi/view?usp=sharing';
$strToArray = explode('|',$string);
echo '<pre>';
print_r($strToArray);
產量
Array
(
[0] => 1
[1] => fuuka-vietsub
[2] => https://drive.google.com/file/d/1tDKPbZ_gaNZrcYHt-tQtcF-TH0hMzGFi/view?usp=sharing
)
現在你可以使用數組鍵0 -> tap
, 1 -> link
, 2 -> player
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.