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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T16:49:43+00:00 2026-06-06T16:49:43+00:00

I use curl to get the content of an website into a string. After

  • 0

I use curl to get the content of an website into a string. After that I want to stip all the whitespace. For that I use $content = preg_replace('/\s+/', '', $content);. But it doesn’t work properly. What am I doing wrong?

I use this code to get the content:

$curl_handle = curl_init();
curl_setopt($curl_handle, CURLOPT_URL, 'http://www.italiakalmar.se/ui/Article/show.aspx?id=185&m=165');
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, true);
$content = curl_exec($curl_handle);
curl_close($curl_handle);

$pos = stripos($content, "<body");
$content = substr($content, $pos);

$content = strip_tags($content);

$content = html_entity_decode($content, ENT_COMPAT, 'UTF-8');

$content = preg_replace('/\s+/', '', $content);

$content = mb_strtolower($content, 'utf-8');

echo $content = str_replace("–", "-", $content);

I then get this string:
//fabrikenrestaurangenpizzerianintromenykvalitetallergihittatillosspizzeriaitaliapizzeriaitaliaöppnadedörrarnaförstagångenredan1977,ochdrivssedandessisammamiljöochsammakaraktäristiskastil.viharalltidutsöktapizzoraverkäntgodsmakochkvalitet.komintillpizzeriaitaliaochlåtossserveradigenutsöktpizza.elleromdetpassarbättre-låtosslevereradenhemtilldig!nukanmanävenbetalamedkortvidutkörning!öppettider:mån-torskl:15-21fredag  kl:15-22lördag  kl:12-22söndag kl:12-21ingårikalmarkrogar.se

As you can see the whitespace is still there.

  • 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-06T16:49:44+00:00Added an answer on June 6, 2026 at 4:49 pm
    $content = str_replace(' ', '', $content);
    

    No regex approach.

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

Sidebar

Related Questions

I use cURL library to get the content of current URL. So I wonder,
I need to get webpage's content ,I cant use Curl as it is not
I found sometimes browser can't get cookies from my website, so I use curl
When I try to use curl command in my shell script I get the
I want to use curl to retrieve a table from an external page. So
I want to use curl in java. Is curl built-in with Java or I
I would like to use a cURL function, but I'm behind a proxy, so
I am trying to use PHP and cURL to log in to a website
I am using cURL to get an XML feed and save it into an
Hi i'm trying to get the content from a json file, but i can't

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.