How to store the title collected by php with curl in the database

I use curl to collect the hyperlink of the title of this site into an array, and then I can"t store it in the database. Baidu has done a lot of ways to convert any array into a string. PS: I am a rookie learning
$body = get ("https://codeshelper.com/");
// initialization
function get ($url) {
$ch = curl_init ()
/ / set options, including URL
curl_setopt ($ch, CURLOPT_URL, "$url");
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt ($ch, CURLOPT_HEADER, 0);
/ execute and get HTML document contents
$output = curl_exec ($ch);
/ release curl handle
curl_close ($ch); < ch > br $br
/ / printed data
preg_match_all ("/ < div class= "mb5 mt5" > < h4 class= "news__item-title mt0" >. ? < / div > < div class= "article-excerpt" >. ? < / div > / ims",$body,$title); * /

$con= mysqli_connect ("localhost","root","root","test"); / / Link
if (! $con) {/ / determine that $con is not equal to return

die("".mysqli_errno());//diemysqli_errno

} else {

echo "";

};
mysqli_set_charset ($con,"utf8");
foreach ($title as $a = > $b) {

$sql= "insert into tex1("username")values(""$b"");"
$result=mysqli_query($con,$sql);

}

if ($result) {

echo "";

} else {

echo"";

}
mysqli_close ($con);
? >
error prompt: Parse error: syntax error, unexpected"$result" (T_VARIABLE) in D:phpStudyWWWindex2.php on line 31
all kinds of errors are reported in foreach anyway. Generally speaking, this function does not exist, or syntax error.
what I want to achieve is that after curl collection, it is stored in the database but stored in [1] of [0] in the array. I belong to learning while taking examples, which has been bothering me for 3 days.

Php
Jun.09,2022

just for this error, the scope of $result is wrong. You have to define $result before the loop, otherwise it cannot be referenced in the later if.
every time you look up the document, it will be helpful to read the following examples clearly.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e4f421-4501d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e4f421-4501d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?