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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:24:40+00:00 2026-06-12T01:24:40+00:00

I write this post because I have this problem: I have a string with

  • 0

I write this post because I have this problem:

I have a string with html characters.

What I want is to remove from this string, all images which are smaller than 10px width. How could I do this in PHP?

I’ve been thinking in the use of some loop but I don’t know how to implement that. Can somebody help me?

  • 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-12T01:24:41+00:00Added an answer on June 12, 2026 at 1:24 am

    You can try

    $final = array();
    $images = array();
    $template = "<img src='%d.jpg' height='%d' width='%d' />";
    
    
    for($i = 0; $i < 10;  $i++)
    {
        $height = mt_rand(9, 12);
        $weight = mt_rand(9, 12);
        $images[] = sprintf($template , $i,$height,$weight);
    
    }
    
    
    var_dump($images);
    
    
    foreach($images as $image)
    {
        $attribute = simplexml_load_string($image);
        $attribute = $attribute->attributes();
    
        if((int) $attribute['height'] <  10 or (int) $attribute['width'] < 10)
            continue ;
        $final[] = $image;
    }
    
    var_dump($final);
    

    Output

    array
      0 => string '<img src='0.jpg' height='11' width='9' />' (length=41)
      1 => string '<img src='1.jpg' height='12' width='9' />' (length=41)
      2 => string '<img src='2.jpg' height='10' width='11' />' (length=42)
      3 => string '<img src='3.jpg' height='12' width='11' />' (length=42)
      4 => string '<img src='4.jpg' height='11' width='9' />' (length=41)
      5 => string '<img src='5.jpg' height='9' width='11' />' (length=41)
      6 => string '<img src='6.jpg' height='9' width='9' />' (length=40)
      7 => string '<img src='7.jpg' height='10' width='9' />' (length=41)
      8 => string '<img src='8.jpg' height='12' width='9' />' (length=41)
      9 => string '<img src='9.jpg' height='10' width='10' />' (length=42)
    array
      0 => string '<img src='2.jpg' height='10' width='11' />' (length=42)
      1 => string '<img src='3.jpg' height='12' width='11' />' (length=42)
      2 => string '<img src='9.jpg' height='10' width='10' />' (length=42)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using the following steps: (I have checked this similar post , which does not
I write this code to get Dunnet anova post hoc test import rpy2.robjects as
I have this small PHP script that takes a POST variable and writes it
I write this in api v2: map.enableGoogleBar(); I want to using v3, but I
I have write this code but it does work only if I am already
I have a Post, to which a migration adds a new attribute and table
I wanted to post this because I was not really sure what issue I
Real deal problem for me, because I have no clue to resolve it. jQuery
I have an HTML form which contains a drop down, a tinyMCE textarea, and
I have the HTML form which do prior upload of files via AJAX. So

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.