我得到了一些牵引力,但是我束手无策。
所以...这里就是...基本上,我需要阅读此数组,找到名称为“ On Call”的数组。然后我需要显示“成员”。
然后,我必须将其推回去,但是如果我能弄清楚如何从头开始,我可能会想出如何扭转它的想法。
我已经尝试过foreach,我曾经尝试过While循环...我已经尝试了两者的组合。
我一直在撞墙,而且似乎不再消失……请帮助。 edit 好像我没有添加我的代码就做成了人造假人,所以这里充满了混乱。我很抱歉。
echo "MainArray<br>";
echo count($mainArray);
echo "<br><br>";
foreach($mainArray["ring_groups"] as $response){
echo "Inside Ring Group Name<br>";
echo $response["name"];
while ($arrayName = current($response["name"])) {
echo $arrayName;
if ($arrayName == 'On Call') {
echo "<table style='border: 1px solid #336699; width:500px'>
<tr>
<td>On Call Person:</td>
<td>";
echo $response["members"];
echo "</td>
</table>";
echo "<br><br>";
print_r($response["members"]);
next($response["name"]);
}
}
}
/* Display Raw Response */
?>
<pre>
Did it work?<br>
<? print_r($response); ?>
Yo!
</pre>
这是主数组的数据转储(print_r):
Array
(
[status] => success
[ring_groups] => Array
(
[0] => Array
(
[ring_group] => 25061
[name] => Normal
[caller_announcement] => 0
[music_on_hold] => default
[language] => en
[members] => account:163768_Adam1,25,0;account:163768_Conf1,25,0;account:163768_Eric1,25,0;account:163768_Fax,25,0;account:163768_FDL1,25,0;account:163768_FDR1,25,0
[voicemail] => 637681
)
[1] => Array
(
[ring_group] => 25069
[name] => Front Desk
[caller_announcement] => 0
[music_on_hold] => default
[language] => en
[members] => account:163768_FDL1,25,0;account:163768_FDR1,25,0
[voicemail] => 637681
)
[2] => Array
(
[ring_group] => 27048
[name] => On Call
[caller_announcement] => 0
[music_on_hold] => default
[language] => en
[members] => fwd:135888,25,0
[voicemail] =>
)
[3] => Array
(
[ring_group] => 54169
[name] => TenX
[caller_announcement] => 0
[music_on_hold] => default
[language] => en
[members] => account:163768_Adam1,25,0;account:163768_Ashleigh,25,0;account:163768_Bryan,25,0;account:163768_Eric1,25,0;account:163768_FDL1,25,0;account:163768_FDR1,25,0
[voicemail] => 10
)
)
)
答案 0 :(得分:0)
也许是这样的:
foreach($main_array['ring_groups'] as $ring_group) {
if($ring_group['name'] == 'On Call') {
$members = explode(";", $ring_group['members'];
foreach($members as $member) {
// here you do your variable separation as you prefer
}
}
}