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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T20:02:51+00:00 2026-06-07T20:02:51+00:00

My PHP script parses a web site and pulls out an HTML DIV that

  • 0

My PHP script parses a web site and pulls out an HTML DIV that looks like this (and saves it as a string)

<div id="merchantinfo">The following merchants: Nautica®, Brookstone®, Teds® ©2012 Blabla</div>

I store this as $merchantList (string).

However, when I output the data to the webpage

echo $merchantList

The encoding gets messed up and displays as:

Nautica®, Brookstone®, Teds® ©2012 Blabla

I tried adding the following to the display page:

<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>

But that didn’t do anything. –Thanks

EDIT:: ————

For the question, the accepted answer is correct.

But I realized my actual issue was slightly different.

The initial parsing using DOMDocument::loadHTML had already mangled the UTF-8 encoding, causing the string to save as

<div id="merchantinfo">The following merchants: Nauticaî, Brookstoneî, Tedsî ©2012 Blabla</div>

This was solved by:

$html = mb_convert_encoding($html, 'HTML-ENTITIES', "UTF-8");
$dom->loadHTML($html);
  • 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-07T20:02:53+00:00Added an answer on June 7, 2026 at 8:02 pm

    Use:

    ini_set('default_charset', 'UTF-8');
    

    And do not use iso-8859-1. Use UTF-8.

    From the mojibake you posted the input string is utf-8, not iso-8859-1.

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

Sidebar

Related Questions

I've written a PHP-script that parses a list from remote website and output the
I need to write a script that takes a link and parses the HTML
I am using a bespoke JQuery/PHP script which parses a Flickr feed using SimpliePie
I have order confirmation html emails being parsed by a PHP script. The script
I have a script that parse the database and create php classes to work
A php script is giving this array (which has been passed through json_encode() )
I used php script to parse remote xml file and print output on web
In my website I've a php script that launches a file download without showing
I have a jquery script that collects data from different sites and saves it
Basically, I'm trying to figure out how PHP can be called from a web

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.