I am trying to get the result as a, b, c, d for my array any format in the textarea field is added
$mydomain = htmlspecialchars($_POST['domainlist']);
$domainlist = preg_replace('/\s+/', '', $mydomain);
$domainlist = preg_replace('#\s+#',',',trim($str));
$domainlist = explode(',', $mydomain);
$keyword = $_POST["keyword"];
foreach($domainlist as $domain) {
$file = file_get_contents('http://' . $domain);
$searchnum = $keyword ;
if (stripos($file, $searchnum) !== false) {
echo 'record found on ' .$domain. '<br/>';
}
else {
echo 'record not found ' .$domain. ' <br/>';
}
}
for example (pay attention to additional free space)
user adds
a,b , c, d
or
a b c d
or
a
b
c
d
everything will lead to
a,b,c,d
which removes an extra space, converts a new line to a comma, or converts a space to a comma and removes extra space
any idea?
source
share