I have php array object and I need display once duplicate field_header in my code. I have html table and want disply once duplicate field_header in table thead and other data in td my array object data this is:
Array
(
[filed_p_1] => stdClass Object
(
[field_id] => 1
[field_table] => product
[field_realname] => field one
[field_namekey] => filed_p_1
[field_header] => number_one
[field_type] => text
)
[filed_p_2] => stdClass Object
(
[field_id] => 2
[field_table] => product
[field_realname] => field two
[field_namekey] => filed_p_2
[field_header] => number_two
[field_type] => text
)
[filed_p_3] => stdClass Object
(
[field_id] => 3
[field_table] => product
[field_realname] => field three
[field_namekey] => filed_p_3
[field_header] => number_three
[field_type] => text
)
[filed_p_1_2] => stdClass Object
(
[field_id] => 19
[field_table] => product
[field_realname] => field four
[field_namekey] => filed_p_1_2
[field_header] => number_one
[field_type] => text
)
)
I want display my result this format:
number_one
field one
field four
number_two
field two
number_three
field three
I'm using foreach loop and display data but my result this is:
foreach ($fields as $fieldName => $oneExtraField) {
?> <thead><tr><th> <?php echo $oneExtraField->field_header; ?></th></tr></thead>
<tr>
<td>
<?php echo $oneExtraField->field_realname ?>
</td>
</tr>
<?php
}
number_one
field one
number_two
field two
number_three
field three
number_one
field four