如何从数组中提取值?
Array
(
[0] => Array
(
[accountNo] => 208773
[mem_id] => 575
[email] => [email protected]
)
)
Array
(
[0] => Array
(
[accountNo] => 9415238
[mem_id] => 619
[email] => [email protected]
)
)
问题是这个数组的索引都是 0。
我如何使用多维数组获取 accountNo、mem_id 和 email 等值?
Array
(
[0] => Array
(
[accountNo] => 208773
[mem_id] => 575
[email] => [email protected]
)
)
Array
(
[0] => Array
(
[accountNo] => 9415238
[mem_id] => 619
[email] => [email protected]
)
)
the problem is that both this array coming as 0 index.
how can i fetch the values like accountNo,mem_id and email using multidimensional array ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
如果他使用 array_merge - 那么他如何确保将正确的电子邮件链接到正确的 accountNo?
不假设电子邮件是来自 accountNo 的 $index+=2 吗?
制作一个循环和匹配的函数怎么样?
还是我误解了一切? - 抱歉,如果是的话。
If he Use array_merge - then how can he be sure to link correct email to correct accountNo?
Without assuming that email is $index+=2 from accountNo?
What about making a function that loops and match?
Or have I misunderstood everything? - Sorry if so.
首先使用 array_merge() ,之后你可以做一个简单的 foreach 并得到$var['accountNo] 的值等等
use array_merge() first, afterwards you could do a simple foreach and get the values by $var['accountNo] and so on
只需进行数组合并
如果你使用 php, ,
1) $array = array_merge($array,$array2);
http://www.php.net/manual/en/function.array -merge.php
just do an array merge
if u r using php,
1) $array = array_merge($array,$array2);
http://www.php.net/manual/en/function.array-merge.php
如果这是来自数据库,并且您正在使用类似 https://www.php.net/manual/en/function.mysql-fetch-assoc.php 那么,这就是它应该看起来的样子。 的方式做一些事情
你会按照“所以,事情就应该这样”
。如果你迫切需要 1 个大的数组来做其他事情,那么你可以在之后合并它们(正如其他人所说)
If this is coming from a database, and you're using something like https://www.php.net/manual/en/function.mysql-fetch-assoc.php then, thats exactly how it should look. You would do something along the lines of
So, thats how it should be.
If you desparately need to have 1 big fat array to do something else with, then you can merge them after (as others have said)
使用
array_merge()
,它就变成了一个数组。Use
array_merge()
and it becomes a single array.