ariefbruce ariefbruce - 1 month ago 5
PHP Question

How to get data result array in php

I have data and stored in database, data return with

result_array()
, when data set to
var_dump()
, result like this:

array(6) {
[0] => array(4) {
["id_termmeta"] => string(1)"1"
["id_term"] => string(1)"1"
["meta_key"] => string(9)"telephone"
["meta_value"] => string(17)"(021) 456 789 xxx"
}
[1] => array(4) {
["id_termmeta"] => string(1)"2"
["id_term"] => string(1)"1"
["meta_key"] => string(11)"handphone_1"
["meta_value"] => string(12)"08567890xxx"
}
[2] => array(4) {
["id_termmeta"] => string(1)"3"
["id_term"] => string(1)"1"
["meta_key"] => string(11)"handphone_2"
["meta_value"] => string(7)"087654321xxx"
}
[3] => array(4) {
["id_termmeta"] => string(1)"4"
["id_term"] => string(1)"1"
["meta_key"] => string(11)"handphone_3"
["meta_value"] => string(8)"081234567xxx"
}
[4] => array(4) {
["id_termmeta"] => string(1)"5"
["id_term"] => string(1)"1"
["meta_key"] => string(6)"alamat"
["meta_value"] => string(16)"Jl. Jalan menuju sorga"
}
[5] => array(4) {
["id_termmeta"] => string(1)"6"
["id_term"] => string(1)"1"
["meta_key"] => string(5)"email"
["meta_value"] => string(20)"blabla@gmail.com"
}
}


I want to get data
meta_value
in
array[0]
,
meta_value
in
array[1]
,
meta_value
in
array[2]
, etc..

How to make like this:

<ul class="list-contact">
<li><a href=""><div class="list-style"><img src="tlpn.png"></div>(021) 456 789 xxx</a></li>
<li><a href=""><div class="list-style"><img src="phone.png"></div> <p>08567890xxx<br>087654321xxx<br>081234567xxx</p></a><a href=""></a></li>
<li><a href=""></a><a href=""><div class="list-style"><img src="marking.png"></div>
<p>Jl. Jalan menuju sorga</p>
</a></li>
<li><a href=""><div class="list-style"><img src="msg.png"></div>blabla@gmail.com </a></li>
</ul>


and the result like this:

Sample output

Answer

Try this code, its worked, thanks @mohade

<ul class="list-contact">
   <li><a href=""><div class="list-style"><img src="tlpn.png"></div><?php echo $contact[0]['meta_value']; ?></a></li>
   <li><a href=""><div class="list-style"><img src="phone.png"></div> <p><?php echo $contact[1]['meta_value']; ?><br><?php echo $contact[2]['meta_value']; ?><br><?php echo $contact[3]['meta_value']; ?></p></a><a href=""></a></li>
   <li><a href=""></a><a href=""><div class="list-style"><img src="marking.png"></div><p><?php echo $contact[4]['meta_value']; ?></p>
                            </a></li>
   <li><a href=""><div class="list-style"><img src="msg.png"></div><?php echo $contact[5]['meta_value']; ?></a></li>
</ul>
Comments