I am learning curl to fetch data from a site. Everything works fine with Curl except for special characters. When I look at the source of the site it has following items.
<li class="page_item page-item"><a href="../categories/mens-health/">Men’s Health</a></li>
<li class="page_item page-item"><a href="../categories/nails-hair-skin/">Nails, Hair & Skin</a></li>
<li class="page_item page-item"><a href="../categories/womens-health/">Women’s Health</a></li>
When I get the data in array and echo it on browser I get the result as
Men’s Health
Nails, Hair & Skin
Women’s Health
which I got by executing the following code
$search = array('’');
$replace = array("'");
$category_names[] = htmlentities(str_replace($search, $replace, $word), ENT_QUOTES);
$word being the 3 array items above. Now I am not able to convert them to proper characters while inserting into database. This is how it appears in my db
Men&#8217;s Health
Nails, Hair &#038; Skin
Women’s Health
How can I insert it in proper format as follows?
Men's health
Nails. Hair & Skin
Women's Health
I checked some of the solutions for having apostrophe but they are mostly single insert statements, where as I am inserting in a loop.
Way to insert text having ' (apostrophe) into a SQL table
How do I escape a single quote in SQL Server?
I did html_entity_decode($category_names[$i]); and now I get the following reult in my database
Men’s Health
Nails, Hair & Skin
Women’s Health