在下拉列表中插入转换谷歌产品分类法



我尝试在下拉列表中转换谷歌产品分类法,但我在循环中被阻止 此外,此行不得出现。

$file = file_get_contents('http://www.google.com/basepages/producttype/taxonomy-with-ids.en-US.txt');
$file = explode("n", $file);
var_dump($fields);

$fields示例:

array(0) { } array(1) { [0]=> string(45) "# Google_Product_Taxonomy_Version: 2019-07-10" } array(1) { [0]=> string(26) "1 - Animals & Pet Supplies" } array(2) { [0]=> string(29) "3237 - Animals & Pet Supplies" [1]=> string(12) "Live Animals" } array(2) { [0]=> string(26) "2 - Animals & Pet Supplies" [1]=> string(12) "Pet Supplies" } 

如何完成? 谢谢。

因此,如果我正确理解了您的问题,则需要从该文件创建一个下拉列表,并且无法创建循环。我不知道是什么

此外,此行不得出现。

意思,但当遵循答案不能满足您的需求时,请随时纠正我。

<?php
$file = file_get_contents('http://www.google.com/basepages/producttype/taxonomy-with-ids.en-US.txt');
$file = explode("n", $file);
?>
<select name="dropdown" class="dropdown">
<option selected="selected">Choose one</option>
<?php
foreach($file as $key =>$value)
{
?>
<option value="<?=$value?>"><?=$value?></option>
<?php
}
?>

最新更新