[英]how to get the value from associative array
I have created an array using array_push in php and I got 我已经在php中使用array_push创建了一个数组,我得到了
[0] => nithya.sreeraman
[1] => jaivignesh.parthiban
[2] => aadhil.ahmed
[3] => aarthe.sathyanaraya
[4] => abdulamjad.babu
[5] => khaja.hussain
[6] => abdulwahab.mohamed
[7] => abdullasha.pari
[8] => abinaya.sambandam
[9] => abinesh.pugazhendhi
I want to collect the value as 我想收集价值为
('nithya.sreeraman','jaivignesh.parthiban','aadhil.ahmed',etc)
Is it possible in php I wnt to collect this value for where column in
QUERY 我是否可以在PHP中收集QUERY中
where column in
此值
$array = array_map(function($v) { return "'{$v}'"; }, $array);
echo "(" . implode(",", $array) . ")";
Use implode
by comma and str_replace
使用逗号和
str_replace
implode
$arr = [0 => 'nithya.sreeraman', 1 => 'jaivignesh.parthiban'];
$string = "('". str_replace(",", "','", implode(',', $arr))."')";
Just use php join 只需使用php join
$array = array_map(function($x) { return "'" . $x . "'"; }, $array);
echo "(" . join(',', $array) . ")";
您可以直接使用爆破功能转换逗号分隔的字符串
$final_output = "('" . implode("','", $your_input_array) . "')";
You just need to run a foreach loop to get the values - 您只需要运行一个foreach循环即可获取值-
$name = array([0] => nithya.sreeraman [1] => jaivignesh.parthiban [2] => aadhil.ahmed
[3] => aarthe.sathyanaraya [4] => abdulamjad.babu [5] => khaja.hussain
[6] => abdulwahab.mohamed [7] => abdullasha.pari [8] => abinaya.sambandam
[9] => abinesh.pugazhendhi);
$i = 0;
// Loop through assoc name array
foreach($name as $key => $value){
$arrName[$i] = $value;
$i++;
}
Your names will be stored in $arrName . 您的姓名将存储在$ arrName中 。
I hope this is what you were looking for :) 我希望这就是你想要的:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.