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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:21:56+00:00 2026-05-25T11:21:56+00:00

at my current website i am using this code to get the first image

  • 0

at my current website i am using this code to get the first image , witch is inside the post

$first_img = '';
    $my1content = AD($row['post_content']);
    $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $my1content, $matches); 
    $first_img = $matches [1] [0];
    if(empty($first_img)){ //Defines a default image
        $first_img = "/img/default.png";
    }

I wanted to know how to get all the images that are in the post, not only the first one.
Thank you for reading this message.

  • 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-25T11:21:57+00:00Added an answer on May 25, 2026 at 11:21 am

    $matches[1] should be an array, iterate over $matches[1] to get all the img tags. This assumes that $my1content has all the content.

    for ($matches[1] as $match) {
        //do the stuff you want to do with a match
        $imgUrl = $match[1]; //Do something with this
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using code that will get the root path return HttpContext.Current.Server.MapPath(@\Schedules\); This works
Using this code (tweaked a little) i can't get a constant Y value. it
i'm trying to create a portfolio website using wordpress, each post has view costum
this is my first time really using this site. I'm relatively new to using
I am working on one project and I am using JavaScript code to get
A client of mine is needing their current website to tie into an online
My current solution consists of several Class Libraries and a Website. I'm in the
My current project is broken down into 3 parts: Website, Desktop Client, and a
My website makes a lot of requests. I often need to cancel all current
I have a few classes in my current project where validation of Email/Website addresses

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.