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

  • SEARCH
  • Home
  • 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 8393317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:45:06+00:00 2026-06-09T19:45:06+00:00

I am trying to get two foreach loop by explode with two delimiters <>

  • 0

I am trying to get two foreach loop by explode with two delimiters <> and "\n" but getting error. Warning: Invalid argument supplied for foreach()

Here is my code

<?php

    $specifications = $scooter_meta->get_the_value('specifications');

    $titles = explode('<>', $specifications);

    $descs = explode("\n", $specifications);

    echo '<dl>';

    foreach($titles as $title => $descs){

        echo '<dt>' . $title . '</dt>';

        foreach($descs as $desc){
            echo '<dd>' . $desc . '</dd>';
        }

    }

    echo '</dl>';

?>

The value entering into textarea something like this Title here<>this is the first scooter ever made.
Title here 2<>another line for specification
In fact I would like to make it like <title 1> here detail text

Thanks a lot

  • 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-09T19:45:07+00:00Added an answer on June 9, 2026 at 7:45 pm

    actually you should do something like this

    <?php
    
    $specifications = $scooter_meta->get_the_value('specifications');
    
    $descs = explode("\n", $specifications);
    
    echo '<dl>';
    
    foreach($descs as $desc){
    
        $title = explode('<>', $desc);
    
        echo '<dt>' . $title[0] . '</dt>';
        for($i=1; $i<=count($title); $i++){
            echo '<dd>' . $title[$i] . '</dd>';
        }
    
    }
    
    echo '</dl>';
    
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to get a timer to count two times but I have
I'm trying to target the last item in a foreach loop but it's acting
Trying to get two checkbox controls to work with each other. Pseudo-code example: If
In C#, I'm trying to get the last two decimal places of a double
In my GWT project, I'm trying to get it so two DialogBoxes can pass
i have two tables i am trying to get information from. login table -
I am trying to get the distance between two location using Google Mps API
I am trying to get all logfiles between two dates with regular expressions. My
I am trying to get the residuals for the scatter plot of two variables.
I have two tables: hotels and hotel_rooms I'm trying to get a table with

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.