0
[
{
    "youname": "a",
    "youemail": "[email protected]",
    "studies": "elementary school",
    "civilstate": "single"
},
{
    "youname": "b",
    "youemail": "[email protected]",
    "studies": "secondary school",
    "civilstate": "single"
}
]

this is my .json file..! iam decoding it and json_decode and converting it to array format as below..

Array ( [0] => Array ( [youname] => a [youemail] => [email protected] [studies] => elementary school [civilstate] => single )
 [1] => Array ( [youname] => b [youemail] => [email protected][studies] => secondary school [civilstate] => single )) 

can some one tell me how can i take 'Youemail' in dropdown list using PHP.

1
  • 1
    if it is valid array you should create loop to get it foreach($array as $item){ echo $item['youemail'];} Commented Sep 19, 2013 at 9:26

2 Answers 2

2

If it's in an array, use $array = and then the array.

You can then do:

<select>
foreach($array as $a)
{
    echo "<option value='".$a['youemail']."'";
}
</select>
Sign up to request clarification or add additional context in comments.

Comments

0

Use:

<?php 
$array = array ( 
    "0" => array(
        "youname" => "a", 
        "youemail" => "[email protected]", 
        "studies" => "elementary school", 
        "civilstate" => "single" 
    ),
    "1" => array( 
        "youname" => "b", 
        "youemail" => "[email protected]",
        "studies" => "secondary school", 
        "civilstate" => "single" 
    )
);

echo "<select>";
foreach($array as $each)
{
    echo "<option value='".$each['youemail']."'>".$each['youemail']."</option>";
}
echo "</select>";
?> 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.