Breaking my head here.
I'm getting data from a website.
$page = file_get_contents('https://somepage.com/example');
I use the following to search for data I want to filter out the information:
preg_match('/class="accent no-margin-bottom inline">(.*?)</', $page, $match);
The value I'm getting is : $ 9'858'470, which is what I want.
I would expect this to be a string value. Since I want to insert this data into a database I would like to remove the $ sign and the single quotes.
I'm trying it this way:
$replacechars = array ("'", "$");
echo $string = str_replace($replacechars, "", $match[1]);
This returns: 9'858'470
I don't understand why I still see the single quotes.
When I just put
$string2 = "9'858'470";
$replacechars = array ("'", "$");
echo $string2 = str_replace($replacechars, "", $string2);
It works. Is there a problem with the value filtered from the webpage?
Updated with my code.
<?php
require 'simple_html_dom.php';
$html = file_get_html('https://swissborg.com/chsb-overview');
$replacechars = array ("'", "$");
preg_match('/class="accent no-margin-bottom inline">(.*?)</', $html, $match);
//echo "<BR>";
var_dump($match[1]);
echo "<BR>";
$string = preg_replace("/[^0-9]/", "", strip_tags(html_entity_decode($match[1])));
var_dump($string);
?>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…