0
[
{
    "youname": "a",
    "youemail": "xyz@gmail.com",
    "studies": "elementary school",
    "civilstate": "single"
},
{
    "youname": "b",
    "youemail": "abcd@gmail.com",
    "studies": "secondary school",
    "civilstate": "single"
}
]

これは私の .json ファイルです..! 以下のように、それと json_decode をデコードし、配列形式に変換します。

Array ( [0] => Array ( [youname] => a [youemail] => xyz@gmail.com [studies] => elementary school [civilstate] => single )
 [1] => Array ( [youname] => b [youemail] => abcd@gmail.com[studies] => secondary school [civilstate] => single )) 

PHPを使用してドロップダウンリストで「Youemail」を取得する方法を教えてください。

4

2 に答える 2

0

使用する:

<?php 
$array = array ( 
    "0" => array(
        "youname" => "a", 
        "youemail" => "xyz@gmail.com", 
        "studies" => "elementary school", 
        "civilstate" => "single" 
    ),
    "1" => array( 
        "youname" => "b", 
        "youemail" => "abcd@gmail.com",
        "studies" => "secondary school", 
        "civilstate" => "single" 
    )
);

echo "<select>";
foreach($array as $each)
{
    echo "<option value='".$each['youemail']."'>".$each['youemail']."</option>";
}
echo "</select>";
?> 
于 2013-09-19T09:32:07.630 に答える