分解后按字母顺序的php输出
我有一根像分解后按字母顺序的php输出,php,Php,我有一根像 $email= "yun@hotmail.com,sibel@hotmail.com,yusufsar@hotmail.com"; 首先我像这样爆炸 $wordChunks = explode(",", $email); for($i = 0; $i < count($wordChunks); $i++){ $eex = mysqli_query($database->connection,"SELECT * FROM contacts where email =
$email= "yun@hotmail.com,sibel@hotmail.com,yusufsar@hotmail.com";
首先我像这样爆炸
$wordChunks = explode(",", $email);
for($i = 0; $i < count($wordChunks); $i++){
$eex = mysqli_query($database->connection,"SELECT * FROM contacts where email = '$wordChunks[$i]' and owner = '$session->username'") or die(mysqli_error());
while($zzz = mysqli_fetch_array($eex)){
if(empty($zzz['bedrijfsnaam'])){
$aa = "<font size='2'>".ucfirst($zzz['name'])." ".ucfirst($zzz['lastname'])."</font>";
}else{
$aa = "<font size='2'>".ucfirst($zzz['bedrijfsnaam'])."</font>";
}
echo $aa;
}
}
$wordChunks=explode(“,”,$email);
对于($i=0;$iconnection,“从联系人中选择*,其中email='$wordChunks[$i]'和owner='$session->username')或die(mysqli_error());
而($zzz=mysqli\u fetch\u数组($eex)){
如果(空($zzz['bedrijfsnaam'])){
$aa=“”.ucfirst($zzz['name'])。“.ucfirst($zzz['lastname'])”;
}否则{
$aa=”“.ucfirst($zzz['bedrijfsnaam']);
}
回音$aa;
}
}
问题是我如何按字母顺序订购$aa
我试过的是
$array = str_split($aa, 1);
sort($array);
foreach ($array as $val) {
echo $val."<br>";
}
$array=str\u split($aa,1);
排序($数组);
foreach($val形式的数组){
echo$val.“
”;
}
但这只订购$aa的字符串;例子
字符串=hellow
输出为ehllow。但是我想在while循环中订购$aa的输出只需使用
$aa = 'hellow';
$array = str_split($aa, 1);
foreach ($array as $val) {
echo $val."<br>";
}
$aa='hellow';
$array=str_split($aa,1);
foreach($val形式的数组){
echo$val.“
”;
}
结果:
h
E
L
L
o
不需要使用explode()并循环它。只需将该字符串放入查询中,它就会工作。将您的查询更改为使用in()搜索电子邮件,并按顺序排序,这样您就可以按升序获取数据。
您可以这样尝试:
$eex = mysqli_query($database->connection,"SELECT * FROM contacts where email IN ($email) and owner = '$session->username' order by email") or die(mysqli_error());
while($zzz = mysqli_fetch_array($eex)){
if(empty($zzz['bedrijfsnaam'])){
$aa = "<font size='2'>".ucfirst($zzz['name'])." ".ucfirst($zzz['lastname'])."</font>";
}else{
$aa = "<font size='2'>".ucfirst($zzz['bedrijfsnaam'])."</font>";
}
echo $aa;
}
$eex=mysqli_query($database->connection,“从联系人中选择*,其中电子邮件($email)和所有者=“$session->username”“order by email”)或死亡(mysqli_error());
而($zzz=mysqli\u fetch\u数组($eex)){
如果(空($zzz['bedrijfsnaam'])){
$aa=“”.ucfirst($zzz['name'])。“.ucfirst($zzz['lastname'])”;
}否则{
$aa=”“.ucfirst($zzz['bedrijfsnaam']);
}
回音$aa;
}
如果我没弄错的话,您可以在SQL语句中按顺序排序。不需要排序,因为db输出是每封电子邮件的一个输出。您找到了如何做到这一点吗?这不是我想要的答案。我必须分解$email,并使用它来获得每封分解电子邮件的db结果。$email中的每个电子邮件地址也位于我数据库的联系人行中,其中包含我需要的信息,如name lastname。。。