2

文字列にアイテムのリストがあります。

$string=Digital SLR & Batteries (Spares if possible), Memory Cards (& Spares), Strong Walking Boots (No Trainers), Warm waterproof clothing, Packed lunch/evening meal (Or both) depending on workshop time, Drinks

配列内のすべての項目が必要なので、for ループを使用してそれらを html リストに出力できます。

これどうやってするの?

4

4 に答える 4

4

あなたのデータはカンマで区切られていることがわかります

$string_array = explode(",", $string);
于 2012-05-14T12:11:05.280 に答える
2
$myArray = explode(',', $string);

これを使用して、文字列を配列に分割できます

于 2012-05-14T12:14:21.600 に答える
2

使用する:

 $pieces = explode(",", $string);

ここで $pieces は次のような配列になります

    $pieces[0]="Digital SLR & Batteries (Spares if possible)";

等々

于 2012-05-14T12:15:33.313 に答える
2

exlode() 関数を使用できます。

<?
$string="Digital SLR & Batteries (Spares if possible), Memory Cards (& Spares), Strong Walking Boots (No Trainers), Warm waterproof clothing, Packed lunch/evening meal (Or both) depending on workshop time, Drinks";

$arr = explode(", ", $string);
foreach ($arr as $element) {
   print $element . "\n";
}
?>
于 2012-05-14T12:16:58.183 に答える