打破和设计PHP数学方程式

时间:2017-01-14 04:54:58

标签: php

如何在每个角色周围放置一个跨度?

<span>1</span>
<span>3</span>
<span>5</span>
<span>6</span>
<span>9</span>

if ($row['make'] == "Hyundai" && $row['mileage'] <= "50000" && date("Y")-5 < $year) {
$remaining = 50000 - $row['mileage'];}

2 个答案:

答案 0 :(得分:1)

我认为这就是你所说的不太确定,因为你所说的并不能解释很多但是你去了

<?php

if ($row['make'] == "Hyundai" && $row['mileage'] <= "50000" && date("Y")-5 < $year) {
    $remaining = 50000 - $row['mileage'];
}
$Split = str_split($remaining);
$spannedArray = array();
foreach ($Split as $char) {
    $newChar = "<span>".$char."</span>";
    array_push($spannedArray, $newChar);
}
foreach ($spannedArray as $spannedChar) {
    echo($spannedChar);
}
?>

答案 1 :(得分:0)

您可以使用strlen()和substr()来计算单个字符,并将标记附加到循环中。

$remaining = 12345;
$length = strlen($test);

for ($i = 0; $i < $length; $i++) {
    echo '<span>' . substr($remaining, $i, 1) . '</span>';
}