Exception or error:
I have tried my regular expression on regex101.com and it works. Cannot seem to figure out why it doesn’t work inside my code.
XML file – schema.xsd:
https://pastebin.com/62xmmymq
Complete Code (line 27 to 47):
https://pastebin.com/gZJ228Fc
Code in a separate file:
<?php
$re = '/<xs:element\sname=\"[a-zA-Z]+\">/';
$filename = "schema.xsd";
$str = file_get_contents($filename);
//echo htmlentities($str);
echo $str;
echo preg_match_all($re, $str, $matches);
// Print the entire match result
//var_dump($matches[0]);
echo "<br><br>";
var_dump($matches[0][0]);
echo "<br>";
echo htmlentities($matches[0][1]);
echo "<br>";
echo htmlentities($matches[0][2]);
echo "<br><br>";
$string = "";
echo "type of dollarstring :" . gettype($string);
/*foreach($matches as $match)
{}*/
$string = implode ($matches);
$file = fopen("test.sql", "w") or die("Unable to open file!");
fwrite($file, $string);
fclose($file);
?>
How to solve: