我有一个
$str ="sometxt<br>another<br>moretext<br>evenmoretext<br>";
我正在尝试每行输出一个数组中的字符串。
有点像..
[0] => Array
(['stuff'] => sometext
)
[1] => Array
(['stuff'] => another
)
[2] => Array
(['stuff'] => moretext
)
[3] => Array
(['stuff'] => evenmoretext
)
我正在使用正则表达式获取str .. 如果你需要更多的澄清......我会做的。提前谢谢
答案 0 :(得分:3)
试试这个:
$arr = explode("<br>", $str);
$resp = array();
foreach ( $arr as $val ){
$resp[] = array("stuff" => $val);
}
我认为这段代码可以解决您的困境。如果您需要任何澄清,请告诉我。
答案 1 :(得分:1)
试试这个:
<?php
$str ="sometxt<br>another<br>moretext<br>evenmoretext<br>";
$r = array("stuff" => explode("<br>", $str));
print_r($r);
?>
Array
(
[stuff] => Array
(
[0] => sometxt
[1] => another
[2] => moretext
[3] => evenmoretext
[4] =>
)
)