I'm trying to loop through an array inside of an array, so that I can display either phone numbers or extension number. For example: If a user has both (phone number and extension number) then I should ONLY display phone number, but sometimes a user has only a extension number then I should display the extension number.
And here's my code:
<table style="padding: 40px;margin-left: -10px;margin-top:-38px;display: inline-block;">
<div style="margin-top:16px;margin-left:10px;">
<input type="checkbox" id="checkAll"/>
</div>
<div style="padding:20px;">
@foreach($resultArray as $key => $value)
@foreach($value as $key2 => $value2)
@if(is_array($value2))
@foreach($value2 as $key3 => $value3)
<?php
// echo var_dump($value3);
if (in_array($value3['phoneNumber'], $value3)) {
if (strlen($value3['phoneNumber']) === 11) {
$value3['phoneNumber'] = ltrim($value3['phoneNumber'], 1);
}
}
else{
$value3['phoneNumber'] = $value3['extension'];
}
?>
<tr>
<td>
<input class="input_checkbox" type="checkbox"
id="{{$key3}}customer-name-checkbox" name="{{$key3}} "
value="yes"><span style="padding-left:40px;"></span>
</td>
<td>{{$value3['firstName']}} {{$value3['lastName']}}</td>
<td>{{$value3['phoneNumber']}}}</td>
<td><input style="margin-left:60px;float: right;" type="email" class="styled-text rounded" name="{{$key3}}" id="{{$key3}}customer-name-inputField" placeholder="" value=""/><br/><br/>
</td>
</tr>
@endforeach
@endif
@endforeach
@endforeach
</div>
</table>
Can someone tell me what I'm doing wrong please? Thank you so much in advance!!
@. Especially, while you try to debug your code.array_key_existsorissetinstead ofin_array($value3['phoneNumber'], $value3).