如何使用“ |”将值从Textarea插入数据库人物?

时间:2019-05-10 10:18:30

标签: php insert textarea

我的桌子 tapphim tap 列, link 列和 player
我想在“ |”之前插入数据在“ |”之后在不同的列上,例如,我将此值输入到textarea:

#data simulation
set.seed(123)
dados <- data.frame(Churn = sample(c("False.", "True."), 5000, replace = TRUE))
summary(dados)  
# Churn     
# False.:2521  
# True. :2479  

head(dados$Churn)
# [1] False. True.  False. True.  True.  False.
# Levels: False. True.

# subsetting
head(dados['Churn'] == 'False.')
# Churn
# [1,]  TRUE
# [2,] FALSE
# [3,]  TRUE
# [4,] FALSE
# [5,] FALSE
# [6,]  TRUE

1 插入 tap 列,将 fuuka-vietsub 插入 link { 3}} 列到播放器
我有index.php的这段代码:

1|fuuka-vietsub|https://drive.google.com/file/d/1tDKPbZ_gaNZrcYHt-tQtcF-TH0hMzGFi/view?usp=sharing

文件api.php:

<form action="api.php" method="post">
<textarea name="themphim" id="themphim"></textarea>
<input type="submit" name="save" value="save"></input>
</form>


谢谢大家!

1 个答案:

答案 0 :(得分:0)

您可以使用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 -> tap1 -> link2 -> player