Array
(
[0] => Array
(
[accountNo] => 208773
[mem_id] => 575
[email] => sagar.epi@gmail.com
)
)
Array
(
[0] => Array
(
[accountNo] => 9415238
[mem_id] => 619
[email] => kDevMail@yahoo.com
)
)
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 ?
首先使用array_merge() ,然后您可以执行简单的foreach并通过$ var ['accountNo]获取值,依此类推
just do an array merge
if ur using php, 1) $array = array_merge($array,$array2); http://www.php.net/manual/en/function.array-merge.php
使用array_merge()
,它将变为单个数组。
If this is coming from a database, and you're using something like http://us3.php.net/manual/en/function.mysql-fetch-assoc.php then, thats exactly how it should look. You would do something along the lines of
while ($row = mysql_fetch_assoc($result)) {
echo $row["userid"];
echo $row["fullname"];
echo $row["userstatus"];
}
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)
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?
function searchAccountNo($match, $multiArr) {
foreach($multiArr as $subArr) {
if($subArr['accountNo'] == $match) {
return $subArr;
}
}
return false;
}
Or have I misunderstood everything? - Sorry if so.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.