If I have array looking like :
Array ( [date_type] => Date [date_text] => 20/12/2012 [place_type] => Place [place_text] => NY )
How can I print result like :
<span>Date</span><div>20/12/2012</div>
<span>Place</span><div>NY</div>
so on.... (if more custom array)
I came to this step now
$custom_info = array (
"date_type" => "Date",
"date_text" => "20/12/2012",
"place_type"=>"Place",
"place_text" => "NY"
) ;
$count = count($custom_info)/2;
for ($i=1; $i<$count; $i++)
{
}
Someone can help me ?
if your array always has the structure that you wrote, use this
tested
explanation:
according to your array structure, you should echo first element’s value in span, and second element’s value in div, and so on:
$i % 2 == 0shows that when it is element number 0, 2, 4 and so on, print in span, and if 1, 3, 5 and so on, print in div.a % bgives the remainder when you divideaonb