timecard array tests - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of timecard array tests.php
- <?php
- $timecards = [];
- array_push(
- $timecards
- ,
- array('order_id' => 8638,
- 'work_date' => 1609650000,
- 'clock_in' => 1609650000,
- 'clock_out' => 1609650000,
- 'reg_hrs' => 0.00,
- 'facility' => 0,
- 'in_hr_min_txt' => '00:00',
- 'out_hr_min_txt' => '00:00',
- 'employer' => 327,
- 'week_start' => 1609650000
- ),
- array('order_id' => 8638,
- 'work_date' => 1609736400,
- 'clock_in' => 1609765200,
- 'clock_out' => 1609779600,
- 'reg_hrs' => 4.00,
- 'facility' => 503,
- 'in_hr_min_txt' => '08:00',
- 'out_hr_min_txt' => '12:00',
- 'employer' => 327,
- 'week_start' => 1609650000
- ),
- array('order_id' => 8638,
- 'work_date' => 1609736400,
- 'clock_in' => 1609781160,
- 'clock_out' => 1609788000,
- 'reg_hrs' => 1.90,
- 'facility' => 503,
- 'in_hr_min_txt' => '12:26',
- 'out_hr_min_txt' => '14:20',
- 'employer' => 327,
- 'week_start' => 1609650000
- ),
- array('order_id' => 8638,
- 'work_date' => 1609822800,
- 'clock_in' => 1609853400,
- 'clock_out' => 1609866000,
- 'reg_hrs' => 3.50,
- 'facility' => 503,
- 'in_hr_min_txt' => '08:30',
- 'out_hr_min_txt' => '12:00',
- 'employer' => 327,
- 'week_start' => 1609650000
- ),
- array('order_id' => 8638,
- 'work_date' => 1609822800,
- 'clock_in' => 1609867800,
- 'clock_out' => 1609882440,
- 'reg_hrs' => 4.07,
- 'facility' => 503,
- 'in_hr_min_txt' => '12:30',
- 'out_hr_min_txt' => '16:34',
- 'employer' => 327,
- 'week_start' => 1609650000
- ),
- array('order_id' => 8638,
- 'work_date' => 1609909200,
- 'clock_in' => 1609938300,
- 'clock_out' => 1609951860,
- 'reg_hrs' => 3.77,
- 'facility' => 503,
- 'in_hr_min_txt' => '08:05',
- 'out_hr_min_txt' => '11:51',
- 'employer' => 327,
- 'week_start' => 1609650000
- ),
- array('order_id' => 8638,
- 'work_date' => 1609909200,
- 'clock_in' => 1609954860,
- 'clock_out' => 1609964160,
- 'reg_hrs' => 2.58,
- 'facility' => 503,
- 'in_hr_min_txt' => '12:41',
- 'out_hr_min_txt' => '15:16',
- 'employer' => 327,
- 'week_start' => 1609650000
- ),
- array('order_id' => 8638,
- 'work_date' => 1609909200,
- 'clock_in' => 1609974180,
- 'clock_out' => 1609976640,
- 'reg_hrs' => 0.68,
- 'facility' => 503,
- 'in_hr_min_txt' => '18:03',
- 'out_hr_min_txt' => '18:44',
- 'employer' => 327,
- 'week_start' => 1609650000
- ),
- array('order_id' => 8638,
- 'work_date' => 1609995600,
- 'clock_in' => 1610026680,
- 'clock_out' => 1610040600,
- 'reg_hrs' => 3.87,
- 'facility' => 504,
- 'in_hr_min_txt' => '08:38',
- 'out_hr_min_txt' => '12:30',
- 'employer' => 327,
- 'week_start' => 1609650000
- ),
- array('order_id' => 8638,
- 'work_date' => 1609995600,
- 'clock_in' => 1610041860,
- 'clock_out' => 1610060580,
- 'reg_hrs' => 5.20,
- 'facility' => 503,
- 'in_hr_min_txt' => '12:51',
- 'out_hr_min_txt' => '18:03',
- 'employer' => 327,
- 'week_start' => 1609650000
- ),
- array('order_id' => 8638,
- 'work_date' => 1610082000,
- 'clock_in' => 1610110800,
- 'clock_out' => 1610117460,
- 'reg_hrs' => 1.85,
- 'facility' => 504,
- 'in_hr_min_txt' => '08:00',
- 'out_hr_min_txt' => '09:51',
- 'employer' => 327,
- 'week_start' => 1609650000
- ),
- array('order_id' => 8638,
- 'work_date' => 1610082000,
- 'clock_in' => 1610119500,
- 'clock_out' => 1610137020,
- 'reg_hrs' => 4.87,
- 'facility' => 503,
- 'in_hr_min_txt' => '10:25',
- 'out_hr_min_txt' => '15:17',
- 'employer' => 327,
- 'week_start' => 1609650000
- ),
- array('order_id' => 8638,
- 'work_date' => 1610168400,
- 'clock_in' => 1610200860,
- 'clock_out' => 1610212680,
- 'reg_hrs' => 3.28,
- 'facility' => 503,
- 'in_hr_min_txt' => '09:01',
- 'out_hr_min_txt' => '12:18',
- 'employer' => 327,
- 'week_start' => 1609650000
- ),
- array('order_id' => 8642,
- 'work_date' => 1609650000,
- 'clock_in' => 1609650000,
- 'clock_out' => 1609650000,
- 'reg_hrs' => 0.00,
- 'facility' => 0,
- 'in_hr_min_txt' => '00:00',
- 'out_hr_min_txt' => '00:00',
- 'employer' => 327,
- 'week_start' => 1609650000
- ),
- array('order_id' => 8642,
- 'work_date' => 1609736400,
- 'clock_in' => 1609766760,
- 'clock_out' => 1609783020,
- 'reg_hrs' => 4.52,
- 'facility' => 405,
- 'in_hr_min_txt' => '08:26',
- 'out_hr_min_txt' => '12:57',
- 'employer' => 327,
- 'week_start' => 1609650000
- ),
- array('order_id' => 8642,
- 'work_date' => 1609736400,
- 'clock_in' => 1609784520,
- 'clock_out' => 1609796880,
- 'reg_hrs' => 3.43,
- 'facility' => 405,
- 'in_hr_min_txt' => '13:22',
- 'out_hr_min_txt' => '16:48',
- 'employer' => 327,
- 'week_start' => 1609650000
- ),
- array('order_id' => 8642,
- 'work_date' => 1609822800,
- 'clock_in' => 1609850940,
- 'clock_out' => 1609869000,
- 'reg_hrs' => 5.02,
- 'facility' => 405,
- 'in_hr_min_txt' => '07:49',
- 'out_hr_min_txt' => '12:50',
- 'employer' => 327,
- 'week_start' => 1609650000
- ),
- array('order_id' => 8642,
- 'work_date' => 1609822800,
- 'clock_in' => 1609870680,
- 'clock_out' => 1609873800,
- 'reg_hrs' => 0.87,
- 'facility' => 405,
- 'in_hr_min_txt' => '13:18',
- 'out_hr_min_txt' => '14:10',
- 'employer' => 327,
- 'week_start' => 1609650000
- ),
- array('order_id' => 8642,
- 'work_date' => 1609909200,
- 'clock_in' => 1609940280,
- 'clock_out' => 1609956420,
- 'reg_hrs' => 4.48,
- 'facility' => 405,
- 'in_hr_min_txt' => '08:38',
- 'out_hr_min_txt' => '13:07',
- 'employer' => 327,
- 'week_start' => 1609650000
- ),
- array('order_id' => 8642,
- 'work_date' => 1609909200,
- 'clock_in' => 1609958100,
- 'clock_out' => 1609969260,
- 'reg_hrs' => 3.10,
- 'facility' => 405,
- 'in_hr_min_txt' => '13:35',
- 'out_hr_min_txt' => '16:41',
- 'employer' => 327,
- 'week_start' => 1609650000
- ),
- array('order_id' => 8642,
- 'work_date' => 1609995600,
- 'clock_in' => 1610025960,
- 'clock_out' => 1610040840,
- 'reg_hrs' => 4.13,
- 'facility' => 405,
- 'in_hr_min_txt' => '08:26',
- 'out_hr_min_txt' => '12:34',
- 'employer' => 327,
- 'week_start' => 1609650000
- ),
- array('order_id' => 8642,
- 'work_date' => 1609995600,
- 'clock_in' => 1610042820,
- 'clock_out' => 1610050380,
- 'reg_hrs' => 2.10,
- 'facility' => 405,
- 'in_hr_min_txt' => '13:07',
- 'out_hr_min_txt' => '15:13',
- 'employer' => 327,
- 'week_start' => 1609650000
- ),
- array('order_id' => 8642,
- 'work_date' => 1610082000,
- 'clock_in' => 1610082000,
- 'clock_out' => 1610082000,
- 'reg_hrs' => 0.00,
- 'facility' => 0,
- 'in_hr_min_txt' => '00:00',
- 'out_hr_min_txt' => '00:00',
- 'employer' => 327,
- 'week_start' => 1609650000
- ),
- array('order_id' => 8642,
- 'work_date' => 1610168400,
- 'clock_in' => 1610200320,
- 'clock_out' => 1610214360,
- 'reg_hrs' => 3.90,
- 'facility' => 405,
- 'in_hr_min_txt' => '08:52',
- 'out_hr_min_txt' => '12:46',
- 'employer' => 327,
- 'week_start' => 1609650000
- ),
- array('order_id' => 8642,
- 'work_date' => 1610168400,
- 'clock_in' => 1610215560,
- 'clock_out' => 1610228760,
- 'reg_hrs' => 3.67,
- 'facility' => 405,
- 'in_hr_min_txt' => '13:06',
- 'out_hr_min_txt' => '16:46',
- 'employer' => 327,
- 'week_start' => 1609650000
- ),
- array('order_id' => 8647,
- 'work_date' => 1609650000,
- 'clock_in' => 1609650000,
- 'clock_out' => 1609650000,
- 'reg_hrs' => 0.00,
- 'facility' => 0,
- 'in_hr_min_txt' => '00:00',
- 'out_hr_min_txt' => '00:00',
- 'employer' => 327,
- 'week_start' => 1609650000
- ),
- array('order_id' => 8647,
- 'work_date' => 1609736400,
- 'clock_in' => 1609788600,
- 'clock_out' => 1609793640,
- 'reg_hrs' => 1.40,
- 'facility' => 504,
- 'in_hr_min_txt' => '14:30',
- 'out_hr_min_txt' => '15:54',
- 'employer' => 327,
- 'week_start' => 1609650000
- ),
- array('order_id' => 8647,
- 'work_date' => 1609822800,
- 'clock_in' => 1609874040,
- 'clock_out' => 1609878960,
- 'reg_hrs' => 1.37,
- 'facility' => 504,
- 'in_hr_min_txt' => '14:14',
- 'out_hr_min_txt' => '15:36',
- 'employer' => 327,
- 'week_start' => 1609650000
- ),
- array('order_id' => 8647,
- 'work_date' => 1609909200,
- 'clock_in' => 1609909200,
- 'clock_out' => 1609909200,
- 'reg_hrs' => 0.00,
- 'facility' => 0,
- 'in_hr_min_txt' => '00:00',
- 'out_hr_min_txt' => '00:00',
- 'employer' => 327,
- 'week_start' => 1609650000
- ),
- array('order_id' => 8647,
- 'work_date' => 1609995600,
- 'clock_in' => 1610048160,
- 'clock_out' => 1610052300,
- 'reg_hrs' => 1.15,
- 'facility' => 504,
- 'in_hr_min_txt' => '14:36',
- 'out_hr_min_txt' => '15:45',
- 'employer' => 327,
- 'week_start' => 1609650000
- ),
- array('order_id' => 8647,
- 'work_date' => 1610082000,
- 'clock_in' => 1610082000,
- 'clock_out' => 1610082000,
- 'reg_hrs' => 0.00,
- 'facility' => 0,
- 'in_hr_min_txt' => '00:00',
- 'out_hr_min_txt' => '00:00',
- 'employer' => 327,
- 'week_start' => 1609650000
- ),
- array('order_id' => 8647,
- 'work_date' => 1610168400,
- 'clock_in' => 1610196540,
- 'clock_out' => 1610200140,
- 'reg_hrs' => 1.00,
- 'facility' => 504,
- 'in_hr_min_txt' => '07:49',
- 'out_hr_min_txt' => '08:49',
- 'employer' => 327,
- 'week_start' => 1609650000
- ),
- array('order_id' => 8651,
- 'work_date' => 1609650000,
- 'clock_in' => 1609650000,
- 'clock_out' => 1609650000,
- 'reg_hrs' => 0.00,
- 'facility' => 0,
- 'in_hr_min_txt' => '00:00',
- 'out_hr_min_txt' => '00:00',
- 'employer' => 327,
- 'week_start' => 1609650000
- ),
- array('order_id' => 8651,
- 'work_date' => 1609736400,
- 'clock_in' => 1609772100,
- 'clock_out' => 1609785420,
- 'reg_hrs' => 3.70,
- 'facility' => 501,
- 'in_hr_min_txt' => '09:55',
- 'out_hr_min_txt' => '13:37',
- 'employer' => 327,
- 'week_start' => 1609650000
- ),
- array('order_id' => 8651,
- 'work_date' => 1609736400,
- 'clock_in' => 1609786440,
- 'clock_out' => 1609797660,
- 'reg_hrs' => 3.12,
- 'facility' => 501,
- 'in_hr_min_txt' => '13:54',
- 'out_hr_min_txt' => '17:01',
- 'employer' => 327,
- 'week_start' => 1609650000
- ),
- array('order_id' => 8651,
- 'work_date' => 1609822800,
- 'clock_in' => 1609854540,
- 'clock_out' => 1609868760,
- 'reg_hrs' => 3.95,
- 'facility' => 501,
- 'in_hr_min_txt' => '08:49',
- 'out_hr_min_txt' => '12:46',
- 'employer' => 327,
- 'week_start' => 1609650000
- ),
- array('order_id' => 8651,
- 'work_date' => 1609822800,
- 'clock_in' => 1609870620,
- 'clock_out' => 1609879560,
- 'reg_hrs' => 2.48,
- 'facility' => 501,
- 'in_hr_min_txt' => '13:17',
- 'out_hr_min_txt' => '15:46',
- 'employer' => 327,
- 'week_start' => 1609650000
- ),
- array('order_id' => 8651,
- 'work_date' => 1609909200,
- 'clock_in' => 1609942020,
- 'clock_out' => 1609954980,
- 'reg_hrs' => 3.60,
- 'facility' => 501,
- 'in_hr_min_txt' => '09:07',
- 'out_hr_min_txt' => '12:43',
- 'employer' => 327,
- 'week_start' => 1609650000
- ),
- array('order_id' => 8651,
- 'work_date' => 1609909200,
- 'clock_in' => 1609958580,
- 'clock_out' => 1609965300,
- 'reg_hrs' => 1.87,
- 'facility' => 501,
- 'in_hr_min_txt' => '13:43',
- 'out_hr_min_txt' => '15:35',
- 'employer' => 327,
- 'week_start' => 1609650000
- ),
- array('order_id' => 8651,
- 'work_date' => 1609995600,
- 'clock_in' => 1610027880,
- 'clock_out' => 1610043060,
- 'reg_hrs' => 4.22,
- 'facility' => 501,
- 'in_hr_min_txt' => '08:58',
- 'out_hr_min_txt' => '13:11',
- 'employer' => 327,
- 'week_start' => 1609650000
- ),
- array('order_id' => 8651,
- 'work_date' => 1609995600,
- 'clock_in' => 1610045220,
- 'clock_out' => 1610054340,
- 'reg_hrs' => 2.53,
- 'facility' => 501,
- 'in_hr_min_txt' => '13:47',
- 'out_hr_min_txt' => '16:19',
- 'employer' => 327,
- 'week_start' => 1609650000
- ),
- array('order_id' => 8651,
- 'work_date' => 1610082000,
- 'clock_in' => 1610082000,
- 'clock_out' => 1610082000,
- 'reg_hrs' => 0.00,
- 'facility' => 0,
- 'in_hr_min_txt' => '00:00',
- 'out_hr_min_txt' => '00:00',
- 'employer' => 327,
- 'week_start' => 1609650000
- ),
- array('order_id' => 8651,
- 'work_date' => 1610168400,
- 'clock_in' => 1610168400,
- 'clock_out' => 1610168400,
- 'reg_hrs' => 0.00,
- 'facility' => 0,
- 'in_hr_min_txt' => '00:00',
- 'out_hr_min_txt' => '00:00',
- 'employer' => 327,
- 'week_start' => 1609650000
- )
- );
- $jobcandarr[8638] =
- array
- ('order_id' => 8638,
- 'candidate_id' => 55915,
- 'bid_amt' => 40.00,
- 'ot_rate' => 1.50,
- 'holiday_rate' => 1.00,
- 'mem_group' => 105,
- 'contract_fee' => 0.0250,
- 'primary_facility' => 1
- );
- $jobcandarr[8642] =
- array('order_id' => 8642,
- 'candidate_id' => 58072,
- 'bid_amt' => 38.00,
- 'ot_rate' => 1.50,
- 'holiday_rate' => 1.00,
- 'mem_group' => 111,
- 'contract_fee' => 0.0250,
- 'primary_facility' => 24
- );
- $jobcandarr[8647] =
- array('order_id' => 8647,
- 'candidate_id' => 59728,
- 'bid_amt' => 70.00,
- 'ot_rate' => 1.50,
- 'holiday_rate' => 1.00,
- 'mem_group' => 389,
- 'contract_fee' => 0.0250,
- 'primary_facility' => 4
- );
- $jobcandarr[8651] =
- array('order_id' => 8651,
- 'candidate_id' => 59761,
- 'bid_amt' => 60.00,
- 'ot_rate' => 1.50,
- 'holiday_rate' => 1.00,
- 'mem_group' => 105,
- 'contract_fee' => 0.0250,
- 'primary_facility' => 2
- );
- //var_dump($jobcandarr);
- $newarr = [];
- $i=0;
- foreach ($timecards as $key1 => $subkey) {
- $prevorder = 0;
- foreach ($subkey as $key => $timeorder) {
- if ($key === 'order_id') {
- // $jobcandorder = array_search($timeorder, array_column($jobcandarr[$i], 'order_id'));
- // echo " timeorder=" . $timeorder . ' and jobcandorder=' . $jobcandorder[$i];
- // echo $jobcandarr[$timeorder]['order_id'];
- if ( $timeorder == $jobcandarr[$timeorder]['order_id'] ) {
- $newarr[] = $subkey + $jobcandarr[$timeorder];
- // echo "),<br> (";
- // $prevorder = $value;
- }
- }
- // echo "'" . $key . "' => ";
- // if ($key === 'in_hr_min_txt' || $key === 'out_hr_min_txt') {
- // echo "'" . $value . "', " . "<br>";
- // }else{
- // echo $value . ", " . "<br>";
- // }
- }
- $i++;
- };
- print_r($newarr);
File Description
- timecard array tests
- PHP Code
- 12 Feb-2021
- 14.26 Kb
You can Share it:
Latest PHP Pastes