Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- foreach($result as $r){
- foreach($ids_time as $time){
- if($r['id_time'] == $time['id']){
- $row[] = $r;
- }
- }
- }
- [0] => Array
- (
- [id] => 93
- [date] => 2017-03-31
- )
- [0] => Array
- (
- [id] => 22
- [id_time] => 93
- [id_client] => 69
- )
- function arr_index($arr, $key) {
- $result = [];
- foreach ($arr as $item) {
- if (isset($item[$key])) {
- $result[$item[$key]] = $item;
- }
- }
- return $result;
- }
- $indexed_time = arr_index($ids_time, 'id');
- $row = array_map(function($item) use($indexed_time) {
- return $indexed_time[$item['time_id']] ?? null;
- }, $result);
- $timesId = [];
- foreach ($ids_time as $time) {
- $timesId[$time['id']] = $time['id'];
- }
- foreach ($result as $r) {
- if (!empty($timesId[$r['id_time']])) {
- $row[] = $r;
- }
- }
Add Comment
Please, Sign In to add comment