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 8132075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:15:27+00:00 2026-06-06T09:15:27+00:00

Data comes from WordPress metabox in a form of single long array. The data

  • 0

Data comes from WordPress metabox in a form of single long array.

The data that I insert in metabox looks like this:

Rhine Riesling1|0,75 l|9,50 &euro

Rhine Riesling2|0,75 l|9,50 &euro

Rhine Riesling3|0,75 l|9,50 &euro

Rhine Riesling4|0,75 l|9,50 &euro

Final output should look like this:

<ul class="listmenuitems" id="listingmenu_1">
    <li><p>Rhine Riesling1 <span>0,75 l</span></p> <span class="listmenuprice">9,50 &euro;</span></li>
    <li><p>Rhine Riesling2 <span>0,75 l</span></p> <span class="listmenuprice">9,50 &euro;</span></li>
    <li><p>Rhine Riesling3 <span>0,75 l</span></p> <span class="listmenuprice">9,50 &euro;</span></li>
    <li><p>Rhine Riesling4 <span>0,75 l</span></p> <span class="listmenuprice">9,50 &euro;</span></li>
</ul>

How would I cut the array values into pieces considering the separator | and then loop through it to create a correctly formatted <li><p>?

I’m reading about PHP’s explode() at the moment.

  • 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-06T09:15:29+00:00Added an answer on June 6, 2026 at 9:15 am

    You can use the PHP explode command. http://php.net/manual/en/function.explode.php

    Loop through your array, on each entry call: explode(“|”, $entry);
    then you can print out what you want like so:

    $input_arr[];
    echo '<ul class="listmenuitems" id="listingmenu_1">';
    for($i=0;i<sizeof($input_arr);$i++) {
    
        $e = explode("|",$input_arr[$i]);
        echo "<li><p>" . $e[0] . "<span>" . $e[1] . "</span></p> <span class=\"listmenuprice\">" . $e[2] . "</span></li>";
    
    }
    

    Note there is on error checking and it is assumed that you have a complete and well formed array input.

    Updated to add foreach 😉
    And if the foreach loop is your fancy…

    $input_arr[];
    echo '<ul class="listmenuitems" id="listingmenu_1">';
    foreach($input_arr as $i) {
    
        $e = explode("|",$i);
        echo "<li><p>" . $e[0] . "<span>" . $e[1] . "</span></p> <span class=\"listmenuprice\">" . $e[2] . "</span></li>";
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Data comes from outside of the program as long array has to be converted
This data comes from a POST form, the idea is to simply add more
Check this example before reading the question - http://www.sqlfiddle.com/#!2/fcf3e/8 The following data comes from
The data that's required for the charts to be drawn comes from an AJAX
I have some data that comes regularily as a dump from a data souce
Crystal Reports in Visual Studio 2008 with C# Normally Data from single column comes
This data comes from an Oracle database and is extracted to flatfiles in encoding
I have three table.2 data comes from 2 table and insert it into another
I am trying to write an insert query which the data comes from a
i am having a string like: funcname(data) ,comes from upstairs.now i want to save

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.