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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:32:25+00:00 2026-05-27T16:32:25+00:00

This is tailing off my other question which was successfully answered: stackoverflow.com/questions/8597929/need-to-create-li-with-list-of-different-links-using-php-explode-method so now

  • 0

This is tailing off my other question which was successfully answered: stackoverflow.com/questions/8597929/need-to-create-li-with-list-of-different-links-using-php-explode-method

so now I have this:

<?php
$separator1 = "\n";
$separator2 = ":";
$textarea = get_custom_field('my_custom_output');
$array = explode($separator1,$textarea);
$output = ''; // initialize the variable
foreach ($array as $item) {
    list($item_text, $item_links) = explode($separator2, trim($item));
    $output .= '<li class="link-class"><a title="' . $item_text . '" href="http://mywebsite.com/' . $item_links . '">' . $item_text . '</a></li>';
}
?>

<ul>
<?php print $output; ?>
</ul>

and that, using the following in a textarea which is defined to “my_custom_output”:

text1:text1-page-url
text2:new-text2-page
text3:different-page-text3

and the result is

text1
text2
text3

which are successfully linked and styled. (i didnt make them links because stackoverflow doesn’t let me post more than two links because i only have 3 rep).

So my next and final desired task is to do this:

text1
description 1
text2
description 2
text3
description 3

where the text1 etc are linked like before but the descriptions are not linked.

So I will do my best, right here in stackoverflow, to try it. However, I expect I will need some help. Let’s go:

<?php
$separator1 = "\n";
$separator2 = ":";
$separator3 = ";";
$textarea = get_custom_field('my_custom_output');
$array = explode($separator1,$textarea);
$output = ''; // initialize the variable
foreach ($array as $item) {
    list($item_text, $item_links) = explode($separator2, trim($item));
    $output .= '<li class="link-class"><a title="' . $item_text . '" href="http://mywebsite.com/' . $item_links . '">' . $item_text . '</a><br /><span class="desc-class">' . $item_desc . '</span></li>';
}
?>

<ul>
<?php print $output; ?>
</ul>

and to use the following in the textarea which is is defined to “my_custom_output”:

text1:text1-page-url;Text1 Description
text2:new-text2-page;Description For Text2
text3:different-page-text3;A Text3 Description

and I need the output to be:

  • text1

    Text1 Description

  • text2

    Description For Text2

  • ..etc

I don’t know if semicolon will work, but I can’t use a space (\s) because there are spaces in the description. I am open to suggestions.

====================================================

MY NEWEST TRY:

<?php
$separator1 = "\n";
$separator2 = ":";
$separator3 = ";";
$textarea = get_custom_field('my_custom_output');
$array = explode($separator1,$textarea);
$output = ''; // initialize the variable
foreach ($array as $item) {
    $itemarray = explode($separator2, trim($item));
    $item_text = $itemarray[0];
    list($item_links, $item_desc) = explode($separator3,$itemarray[1]);

    $output .= '<li class="link-class"><a title="' . $item_text . '" href="http://mywebsite.com/' . $item_links . '">' . $item_text . '</a><br /><span class="desc-class">' . $item_desc . '</span></li>';
}
?>

<ul>
<?php print $output; ?>
</ul>

IT WORKS!!! =D

  • 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-05-27T16:32:25+00:00Added an answer on May 27, 2026 at 4:32 pm

    Not sure if I understand this well enough (I’m not sure what get_custom_field() gets you – can’t find that as a regular PHP function), but when you explode an item that has multiple instances of the delimiter, you’ll get multiple arrays.

    So:

    $textarea = "text1:text1-page-url;Text1 Description";
    $data = explode(':',$textarea);
    // at this point $data[0] will contain "text1", while $data[1] contains text1-page-url;Text1 Description"
    $descarray = explode(';',$data[1]);
    // then $descarray[0] contains "text1-page-url" and $descarray[1] contains "Text1 Description" so you can echo this out however you like. 
    

    To work with your code..
    Assume each $item is each row at this point, like this:

    $item = "text1:text1-page-url;Text1 Description";
    

    Then this will do the trick:

    foreach ($array as $item) {
        $itemarray = explode($separator2, trim($item));
        $item_text = $itemarray[0];
        list($item_links, $item_desc) = explode(';',$itemarray[1]);
    
        $output .= '<li class="link-class"><a title="' . $item_text . '" href="http://mywebsite.com/' . $item_links . '">' . $item_text . '</a><br /><span class="desc-class">' . $item_desc . '</span></li>';
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I started off with the answer to this question . I decided I wanted
I know how to do this in other languages, but not in C++, which
So I know this question has been asked 20 other times and 20 different
At this question: mod rewrite to remove file extension, add trailing slash, remove www
this is my first question in here, and I would like to ask if
This question is directly related to this SO question I posed about 15 minutes
This question is kind of a follow up to this question I asked a
I know this question was asked a number of times on this site alone,
This question is about variable naming style in objective c and cocoa. I just
I have a table in MS Access database and need to create a query

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.