$string = “123.jpg@123#456.jpg@456#789.jpg@789#abc.jpg@abc”
用PHP将用@和#相连的上述字符串拆分并输出为以下形式
<div class="card actress">
<a href="/card/123"><img class="xx" src="123.jpg"></a>
<div class="card-body">
<h6 class="card-title"><a href="/card/123">123</a></h6>
</div>
</div>
<div class="card actress">
<a href="/card/456"><img class="xx" src="456.jpg"></a>
<div class="card-body">
<h6 class="card-title"><a href="/card/456">456</a></h6>
</div>
</div>
<div class="card actress">
<a href="/card/789"><img class="xx" src="789.jpg"></a>
<div class="card-body">
<h6 class="card-title"><a href="/card/789">789</a></h6>
</div>
</div>
<div class="card actress">
<a href="/card/abc"><img class="xx" src="abc.jpg"></a>
<div class="card-body">
<h6 class="card-title"><a href="/card/abc">abc</a>
</h6>
</div>
</div>
我猜大概是下面这样写,但是就是写不出来想要的结果。
$string = “123.jpg@123#456.jpg@456#789.jpg@789#abc.jpg@abc”
$arr = preg_split("/(#l@)/" ,$string);
$length = strlen($arr);
$thisWord = array();
for ($i=0; $i<$length; $i++) {
$thisWord[$i] = $string[$i];
}