So it looks like you are trying to string manipulate JSON to try to make some sort of associative array. Replacing the : with => is not the right move here…
<?php include_once('simple_html_dom.php'); ?>
<!DOCTYPE html>
<html>
<head>
<title> HTML DOM Parser</title>
</head>
<body>
<?php
header('Content-Type: text/html; charset=utf-8');
set_time_limit(0);
$html=file_get_html('https://www.monreseauplus.com/villes/');
$array[]=array();
$array3[]=array();
foreach($html->find('.ul. li.cat-item a') as $elements){
$array2=$elements->title;
$array=json_decode($array2,true)
$arraynospec=htmlspecialchars_decode($array);
var_dump($arraynospec);
}
?>
</body>
</html>
Try that
This is the problem: $array=str_replace(':','=>',$array2);
Looks like it was already in JSON!
14
solved How to convert String Array to Real array PHP