I have this code which i am using to present my data in a table format
<style>
td{
border:1px solid orange;
}
table{
border:1px solid orange;
}
</style>
<?php
$arr = array(
'one' => array(
'sidebarname' => 'first',
'sidebarid' => 'first1'
),
'two' => array(
'sidebarname' => 'oneaa',
'sidebarid' => 'onebb'
),
'three' => array(
'sidebarname' => 'onecc',
'sidebarid' => 'onedd'
),
'four' => array(
'sidebarname' => 'oneee',
'sidebarid' => 'oneff'
),
'five' => array(
'sidebarname' => 'onegg',
'sidebarid' => 'onehh'
),
'six' => array(
'sidebarname' => 'oneii',
'sidebarid' => 'onejj'
)
);
echo '<table>';
foreach ($arr as $key => $value) {
echo '<tr>'.'<td>'."<input type='text' value=$key />".'</td>';
foreach ($value as $keyed=> $newvalue)
echo '<td>'."<input type='text' value=$newvalue />".'</td>';
}
echo '</tr></table>';
?>
I am displaying the main key of each array and values of the first and second arrays.For instance
'five' => array(
'sidebarname' => 'onegg',
'sidebarid' => 'onehh'
),
i am displaying five,the value of sidebarname and the value of sidebarid.This is what i am expecting in html.
How can i use foreach to display sidebarid as a textarea instead of the input text.
You should remove the second
foreachas you already know the keys: