我有一个阵列,产生于我管理的一个问题。 它希望:
$arr[$i][ id ] = $id;
$arr[$i][ name ] = $name;
$arr[$i][ email ] = $email;
我如何能够从电子邮件一栏中获得独特的价值? 我赞赏这一帮助。
我有一个阵列,产生于我管理的一个问题。 它希望:
$arr[$i][ id ] = $id;
$arr[$i][ name ] = $name;
$arr[$i][ email ] = $email;
我如何能够从电子邮件一栏中获得独特的价值? 我赞赏这一帮助。
采用MySQL中的DISTINCT方法在你一栏中过滤,或使用类似材料
$uniqueEmails = array();
foreach($arr as $array)
{
if(!in_array($array[ email ], $uniqueEmails)
$uniqueEmails[] = $array[ email ];
}
最好的答案是:
array_unique(array_column($arr, email ))
Since PHP 5.5, a new function called array_column() is also available. You can use it following way:
$allEmails = array_column($arr, email );
$uniqueEmails = array_unique($allEmails);
考虑相同的阵列,但背后为第3指数:
$all_array = Array
(
[0] => Array
(
[id] => 1
[value] => 111
)
[1] => Array
(
[id] => 2
[value] => 222
)
[2] => Array
(
[id] => 3
[value] => 333
)
[3] => Array
(
[id] => 4
[value] => 111
)
)
如今,“一”和“四”都有同样的价值。 因此,我们想删除其中的任何内容:
$unique_arr = array_unique( array_column( $all_array , value ) );
print_r( array_intersect_key( $all_array, $unique_arr ) );
如果你通过电子邮件从Kingk获得名单,可以通过像Gardet这样的阵列来改善业绩,而只是将目前的电子邮件地址与最后插入的电子邮件地址相比较。 下面是这方面的法律实例:
$uniqueEmails = array();
$lastemail = ;
foreach($arr as $array)
{
if($array[ email ] != $lastemail)
{
$uniqueEmails[] = $array[ email ];
$lastemail = $array[ email ];
}
}
由于购买力平价不会允许在相同的阵列中重复钥匙,你可以说:
$unique = array_column($arr, email , email );
这将形成一个联系阵列,其中钥匙与价值相同,不可能存在重复价值。
从此点起,您将array_ Values(
)称作该数据(如果需要一个指数阵列)。
请注意,任何一栏数值如用作钥匙,将由购买力平价修改,则不可靠。 例如,如果您有<代码>null值,则钥匙将出现在0<>>>>>>>>上,如果作为钥匙被转换为
在转换成钥匙时改为0
的非致命值,则会发生碰撞。 另一个例子是,将<代码>0.90
。 当然,不能将非标准价值转换为钥匙——因此,这种假设不合适。
I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...
<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...
I found this script online that creates a thumbnail out of a image but the thumbnail image is created with poor quality how can I improve the quality of the image. And is there a better way to create ...
如何确认来自正确来源的数字。
Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...
I wonder there is a way to post a message to a facebook business page with cURL? thanks
I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...
How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...