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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:25:17+00:00 2026-05-31T04:25:17+00:00

Is it possible to get a certain class name through cURL? For instance, I

  • 0

Is it possible to get a certain class name through cURL?

For instance, I just want to get the 123 in this <div class="123 photo"></div>.

Is that possible?

Thanks for your responses!

Edit:

If this is whats seen on a website

<div class="444 photo">...</div>
<div class="123 photo">...</div>
<div class="141 photo">...</div>

etc...

I’m trying to get all the numbers of this class, and putting in an some array.

  • 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-31T04:25:18+00:00Added an answer on May 31, 2026 at 4:25 am

    cURL is only half the solution. Its job is simply to retrieve the content. Once you have that content, then you can do string or structure manipulation. There are some text functions you could use, but it seems like you’re looking for something specific among this content, so you may need something more robust.

    Therefore, for this HTML content, I’d suggest researching DOMDocument, as it will structure your content into an XML-like hierarchy, but is more forgiving of the looser nature of HTML markup.

    $ch = curl_init();
    // [Snip cURL setup functions]
    $content = curl_exec($ch);
    
    $dom = new DOMDocument();
    @$dom->loadHTML($content); // We use @ here to suppress a bunch of parsing errors that we shouldn't need to care about too much.
    
    $divs = $dom->getElementsByTagName('div');
    foreach ($divs as $div) {
        if (strpos($div->getAttribute('class'), 'photo') !== false) {
          // Now we know that our current $div is a photo
          $targetValue = explode(' ', $dom->getAttribute('class'));
    
          // $targetValue will now be an array with each class definition.
          // What is done with this information was not part of the question,
          //   so the rest is an exercise to the poster.
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is is possible to get login credentials such as name/id if user does login
Suppose I want to create trees of a certain set depth, that is, the
Possible Duplicate: To get parent class using Reflection on C# I am trying to
Is this possible? If so, I can't seem to get the syntax right. (C++
Occasionally, during development/debugging, I want to ensure that an object is of a certain
I want to query the datastore for Expando entities that have a certain dynamic
I have a control that looks along the lines of this: public class MyControl
I have a base class that is marked as abstract. Is it possible to
Possible Duplicate: Get CVS history for a particular user Is it possible to list
Possible Duplicate: Get all files from VSS for a given date? I need to

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.