I have table1 with phone numbers with data like 09454151,094949154 and other data about client.
My input data was in phone number like: 000385926555494 or 0385981961969 that i convert to: 0926555494 or 0981961969
That works fine with code (where $broj00 = '000385926555494 '):
$broj00 = preg_replace('/'.ULAZNI_POZIV.'/', '', $broj);
//dodavanje prefixa za ljepsi pregeld broja
$prfix = 0;
$broj01 = array($prefix,$broj00);
$broj02 = implode('',$broj01);
Then i have problem, its work only if $broj is only one data but i can have in $broj = '09846646646,098956565,0989898' like 3 number in date.
How i can explode all that 3 number like one ? And search database for that number for name and return name?
Full code working with $broj = '0986464646'; -> only one number.
function realbroj_ul($broj){
global $database;
global $session;
$result = "";
//uklanjanje odredenog djela iz broja
$broj00 = preg_replace('/'.ULAZNI_POZIV.'/', '', $broj);
//dodavanje prefixa za ljepsi pregeld broja
$prefix = 0;
$broj01 = array($prefix,$broj00);
$broj02 = implode('',$broj01);
if ($broj02 != ''){
$sql = "SELECT * FROM imenik WHERE broj='$broj02'";
$query = $database->query($sql);
$row = $database->fetch_array($query);
if ($row['id'] != ''){
$ime = $row['ime'];
$prezime = $row['prezime'];
$arry = array($ime,$prezime);
$fime = implode(" ", $arry);
$result = "<a style='color:green;' href='index.php?stranica=imenik&korisnik=".$broj02."'>".$fime." (".$broj02.")<i class='material-icons' style='margin-top: -2px;position: absolute;color: green;margin-left: 5px;'>search</i></a>";
}else{
$result = "".$broj02." <a href='index.php?stranica=imenik-add&broj=".$broj02."' alt='Dodaj u imenik'><i class='material-icons' style='margin-top: -4px;position: absolute;color: blue;margin-left: 5px;'>add_circle</i>";
}
}
return $result;
}