Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8812029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:30:36+00:00 2026-06-14T03:30:36+00:00

If I have array looking like : Array ( [ date _type] => Date

  • 0

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 ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T03:30:38+00:00Added an answer on June 14, 2026 at 3:30 am

    if your array always has the structure that you wrote, use this

        $i = 0;
        foreach ($custom_info as $k => $v) {
            if ($i % 2 == 0){
                echo "<span>".$v."</span>";
            } else {
                echo "<div>".$v."</div>";
            }
    
            $i++;
        }
    

    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 == 0 shows 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 % b gives the remainder when you divide a on b

    $i = 0,  $i % 2 --> 0
    $i = 1,  $i % 2 --> 1
    $i = 2,  $i % 2 --> 0
    $i = 3,  $i % 2 --> 1
    $i = 4,  $i % 2 --> 0
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have and associated array looking like this: array(225) { [0]=> array(3) { [id]=>
I have an array of cities and ID's looking like: Brønderslev|810,Frederikshavn|813,Hjørring|860,Jammerbugt|849,Læsø|825,Mariagerfjord|846,Morsø|773,Rebild|840,Thisted|787,Vesthimmerland|820,Aalborg|851 I do not
I have a map array with objects stuffed with variables looking like this: var
I have an PHP array looking like this: $array['my_data']['value'] = 'some value'; $array['my_own_data']['value'] =
I'm looking to slice a two dimensional array in C#. I have double[2,2] prices
I have array like this: $path = array ( [0] => site\projects\terrace_and_balcony\mexico.jpg [1] =>
I have a .plist file that looks like this: <plist version=1.0> <array> <dict> <key>name</key>
I have an array which contains lots of info like lat,lon,city name etc.But all
I have create a Web Service which returns an array of elements like these:
I am looking to do this : I have two field 1. Date -

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.