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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:41:45+00:00 2026-05-27T10:41:45+00:00

<li class=page_item page-item-6><a href=http://localhost/wordpress1006/?page_id=6>About us</a></li> <li class=page_item page-item-12><a href=http://localhost/wordpress1006/?page_id=12>Contact</a></li> <li class=page_item page-item-10><a href=http://localhost/wordpress1006/?page_id=10>Portfolio</a></li> <li

  • 0
<li class="page_item page-item-6"><a href="http://localhost/wordpress1006/?page_id=6">About us</a></li> 
<li class="page_item page-item-12"><a href="http://localhost/wordpress1006/?page_id=12">Contact</a></li> 
<li class="page_item page-item-10"><a href="http://localhost/wordpress1006/?page_id=10">Portfolio</a></li> 
<li class="page_item page-item-8"><a href="http://localhost/wordpress1006/?page_id=8">Services</a></li> 

I need to pull links only from this list, I would use regular expressions but I’m too scared to try.
So numbers will change at the end of page_item page-item-number

what would you suggest me to do here?

Thanks in advance

  • 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-27T10:41:46+00:00Added an answer on May 27, 2026 at 10:41 am

    Try this:

    $matches = array();
    $string = '
        <li class="page_item page-item-6"><a href="http://localhost/wordpress1006/?page_id=6">About us</a></li> 
        <li class="page_item page-item-12"><a href="http://localhost/wordpress1006/?page_id=12">Contact</a></li> 
        <li class="page_item page-item-10"><a href="http://localhost/wordpress1006/?page_id=10">Portfolio</a></li> 
        <li class="page_item page-item-8"><a href="http://localhost/wordpress1006/?page_id=8">Services</a></li> 
    ';
    preg_match_all('/href="(.*?)"/i', $string, $matches);
    var_dump($matches[1]);
    

    Output:

    array
      0 => string 'http://localhost/wordpress1006/?page_id=6' (length=41)
      1 => string 'http://localhost/wordpress1006/?page_id=12' (length=42)
      2 => string 'http://localhost/wordpress1006/?page_id=10' (length=42)
      3 => string 'http://localhost/wordpress1006/?page_id=8' (length=41)
    

    (note it will fail on more complex HTML, in which case I would no longer use Regex, rather some thing like Simple HTML DOM)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have menu structure like below, <ul> <li class=menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-1406
So my list looks something like this: <div=list> <ul> <li class=page item>Parent 1 <ul>
Example of WordPress default CSS class output: <li id=menu-item-55 class=menu-item menu-item-type-post_type menu-item-object-page menu-item-55> <li
I have a class Page that creates an instance of DB , which is
I've got a set of models that look like this: class Page(models.Model): title =
I have the following types and classes: namespace MVC.Models public class Page { public
In C#, I have a class set up like so: class Page { public
I have a class named Page with a private property currently called _pageData which
I've got a Page class in my .edmx ADO.NET Entity Data Model file with
Given this class public partial class Default : Page { private IRepository repo; ...

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.