I am working on this hashtag system. am trying to get the hashtag words into the database in a new row. for every hashtag word i need it to insert into a new row. Below is my php line of code...
$string = filter_var("#hello #world", FILTER_SANITIZE_STRING);
preg_match_all('/(?<!\w)#\w+/', $string, $matches);
foreach ($matches as $key => $value) {
$stmt = $mysqli->prepare("INSERT INTO hash_tag (tagged_word) VALUES (?)");
$stmt->bind_param("s", $value);
$stmt->execute();
}
doing it this way it doesnt insert anything into the database but when i replace the $value to $value[0], it input the first which is #hello.
I want to input both #hello and #world into the database as a new row.
Thanks in advance.