I'm trying to remove an element.
I've a reservation with:
$StartTime = "14:00"; $EndTime = "16:30";
and Array with
Array
(
[Tennis 1] => Array
(
[IntervalTime] => Array
(
[Lun] => Array
(
[0] => 10:00
[1] => 11:00
[2] => 12:00
[3] => 13:00
[4] => 14:00
[5] => 15:00
[6] => 16:00
[7] => 17:00
[8] => 18:00
[9] => 19:00
[10] => 20:00
)
[Mar] => Array
(
[0] => 12:00
[1] => 13:00
[2] => 14:00
[3] => 15:00
)
[Mer] => Array
(
[0] => 09:00
[1] => 10:00
[2] => 11:00
[3] => 12:00
[4] => 13:00
)
[Gio] => Array
(
[0] => 09:00
[1] => 10:00
[2] => 11:00
[3] => 12:00
[4] => 13:00
)
[Ven] => Array
(
[0] => 09:00
[1] => 10:00
[2] => 11:00
[3] => 12:00
[4] => 13:00
)
[Sab] => Array
(
[0] => 09:00
[1] => 10:00
[2] => 11:00
[3] => 12:00
[4] => 13:00
[5] => 14:00
[6] => 15:00
[7] => 16:00
[8] => 17:00
[9] => 18:00
)
[Sun] => Array
(
[0] => 09:00
[1] => 10:00
[2] => 11:00
[3] => 12:00
[4] => 13:00
[5] => 14:00
[6] => 15:00
[7] => 16:00
[8] => 17:00
[9] => 18:00
)
)
)
I need to remove element between $StartTime and $EndTime
so for "Lun" array need to be removed:
[0] => 10:00
[1] => 11:00
[2] => 12:00
[3] => 13:00
[4] => 14:00 // need remove
[5] => 15:00 // need remove
[6] => 16:00 // need remove
[7] => 17:00
[8] => 18:00
[9] => 19:00
[10] => 20:00
I would to foearch the time from Start to End date, and then remove with:
unset($DisponibilitaRoom[$Nomeroom]["IntervalTime"]["Lun"][$index]);
You correct - simple unset should do it - but you need to loop on the times and remove them as:
foreach($arr['Tennis 1']['IntervalTime']['Lun'] as $k => $v) {
if ($v >= $StartTime && $v < $EndTime)
unset($arr['Tennis 1']['IntervalTime']['Lun'][$k]);
}
Live example: 3v4l
Or you can use array-filter as
$arr['Tennis 1']['IntervalTime']['Lun'] = array_filter($arr['Tennis 1']['IntervalTime']['Lun'], function ($v) use ($StartTime, $EndTime) {
return !($v >= $StartTime && $v < $EndTime);
} );
You can use array_walk_recursive with array_map and array_filter
array_walk_recursive($a['Tennis 1']['IntervalTime'], function(&$v) use ($StartTime, $EndTime){
if($v >= $StartTime && $v <= $EndTime) $v = false;
});
$f['Tennis 1']['IntervalTime'] = array_map('array_filter', $a['Tennis 1']['IntervalTime']);
print_r($f);
Working example :- https://3v4l.org/4tNEM
Related
I am trying to use foreach loop on smarty to list all the lockers/carriers from an array. I suspect there might be something wrong with the array but I can't pinpoint the problem.
My code is:
{foreach from=$delivery_points.lockers item=carrier name=myLoop}
<option value="{$carrier->id}"
{if $carrier->id eq $selected_deliveryID } selected {/if}
> {$carrier.address->name|escape:'htmlall':'UTF-8'}
{$carrier->street|escape:'htmlall':'UTF-8'}
{$carrier->postalCode|escape:'htmlall':'UTF-8'}
<!-- {* {$carrier->City|escape:'htmlall':'UTF-8'} *} -->
</option>
{/foreach}
My array is:
Array ( [lockers] => Array ( [0] => Array ( [id] => BOX2756 [address] => Array ( [street] => Puijonkatu 23 [postalCode] => 70100 [city] => Kuopio [country] => FI [coordinate] => Array ( [latitude] => 62.893268049685 [longitude] => 27.68189435171 ) ) [name] => Kauppakeskus Sektori [directions] => Budbee Box sijaitsee Kauppakeskus Sektorin liukuportaiden vieressä. [openingHours] => Array ( [periods] => Array ( [0] => Array ( [open] => Array ( [day] => MONDAY [time] => 08:00 ) [close] => Array ( [day] => MONDAY [time] => 18:00 ) ) [1] => Array ( [open] => Array ( [day] => TUESDAY [time] => 08:00 ) [close] => Array ( [day] => TUESDAY [time] => 18:00 ) ) [2] => Array ( [open] => Array ( [day] => WEDNESDAY [time] => 08:00 ) [close] => Array ( [day] => WEDNESDAY [time] => 18:00 ) ) [3] => Array ( [open] => Array ( [day] => THURSDAY [time] => 08:00 ) [close] => Array ( [day] => THURSDAY [time] => 18:00 ) ) [4] => Array ( [open] => Array ( [day] => FRIDAY [time] => 08:00 ) [close] => Array ( [day] => FRIDAY [time] => 18:00 ) ) [5] => Array ( [open] => Array ( [day] => SATURDAY [time] => 09:00 ) [close] => Array ( [day] => SATURDAY [time] => 15:00 ) ) ) [weekdayText] => Array ( [0] => maanantaina: 08 – 18 [1] => tiistaina: 08 – 18 [2] => keskiviikkona: 08 – 18 [3] => torstaina: 08 – 18 [4] => perjantaina: 08 – 18 [5] => lauantaina: 09 – 15 [6] => sunnuntaina: Closed ) ) [estimatedDelivery] => 2022-03-09T12:30:00.000Z [cutoff] => 2022-03-06T17:18:52.665Z [distance] => 3877 [label] => Kauppakeskus Sektori (9.3.2022 ~14:30) ) [1] => Array ( [id] => BOX2736 [address] => Array ( [street] => Särkiniementie 1 [postalCode] => 70700 [city] => Kuopio [country] => FI [coordinate] => Array ( [latitude] => 62.880945998267 [longitude] => 27.634710015346 ) ) [name] => Kuopio Neste K Särkiniemi [directions] => Budbee Box sijaitsee liikkeen sisällä juomahyllyjä vastapäätä. [openingHours] => Array ( [periods] => Array ( [0] => Array ( [open] => Array ( [day] => MONDAY [time] => 06:30 ) [close] => Array ( [day] => MONDAY [time] => 21:00 ) ) [1] => Array ( [open] => Array ( [day] => TUESDAY [time] => 06:30 ) [close] => Array ( [day] => TUESDAY [time] => 21:00 ) ) [2] => Array ( [open] => Array ( [day] => WEDNESDAY [time] => 06:30 ) [close] => Array ( [day] => WEDNESDAY [time] => 21:00 ) ) [3] => Array ( [open] => Array ( [day] => THURSDAY [time] => 06:30 ) [close] => Array ( [day] => THURSDAY [time] => 21:00 ) ) [4] => Array ( [open] => Array ( [day] => FRIDAY [time] => 06:30 ) [close] => Array ( [day] => FRIDAY [time] => 21:00 ) ) [5] => Array ( [open] => Array ( [day] => SATURDAY [time] => 08:00 ) [close] => Array ( [day] => SATURDAY [time] => 21:00 ) ) [6] => Array ( [open] => Array ( [day] => SUNDAY [time] => 09:00 ) [close] => Array ( [day] => SUNDAY [time] => 21:00 ) ) ) [weekdayText] => Array ( [0] => maanantaina: 06 – 21 [1] => tiistaina: 06 – 21 [2] => keskiviikkona: 06 – 21 [3] => torstaina: 06 – 21 [4] => perjantaina: 06 – 21 [5] => lauantaina: 08 – 21 [6] => sunnuntaina: 09 – 21 ) ) [estimatedDelivery] => 2022-03-09T12:00:00.000Z [cutoff] => 2022-03-06T17:18:52.673Z [distance] => 5758 [label] => Kuopio Neste K Särkiniemi (9.3.2022 ~14:00) ) [2] => Array ( [id] => BOX2755 [address] => Array ( [street] => Savilahdentie 10 [postalCode] => 70700 [city] => Kuopio [country] => FI [coordinate] => Array ( [latitude] => 62.887744149582 [longitude] => 27.634239326918 ) ) [name] => Prisma Kuopio [directions] => Löydät Budbee Boxin myymälän vasemman sisäänkäynnin läheisyydestä, leipomon jälkeiseltä automaattialueelta. Huomaa ettei myymälän muut kaikki sisäänkäynnit ole avoinna 24/7. [openingHours] => Array ( [periods] => Array ( [0] => Array ( [open] => Array ( [day] => MONDAY [time] => 00:00 ) [close] => Array ( [day] => MONDAY [time] => 23:30 ) ) [1] => Array ( [open] => Array ( [day] => TUESDAY [time] => 00:00 ) [close] => Array ( [day] => TUESDAY [time] => 23:30 ) ) [2] => Array ( [open] => Array ( [day] => WEDNESDAY [time] => 00:00 ) [close] => Array ( [day] => WEDNESDAY [time] => 23:30 ) ) [3] => Array ( [open] => Array ( [day] => THURSDAY [time] => 00:00 ) [close] => Array ( [day] => THURSDAY [time] => 23:30 ) ) [4] => Array ( [open] => Array ( [day] => FRIDAY [time] => 00:00 ) [close] => Array ( [day] => FRIDAY [time] => 23:30 ) ) [5] => Array ( [open] => Array ( [day] => SATURDAY [time] => 00:00 ) [close] => Array ( [day] => SATURDAY [time] => 23:30 ) ) [6] => Array ( [open] => Array ( [day] => SUNDAY [time] => 00:00 ) [close] => Array ( [day] => SUNDAY [time] => 23:30 ) ) ) [weekdayText] => Array ( [0] => maanantaina: 00 – 23 [1] => tiistaina: 00 – 23 [2] => keskiviikkona: 00 – 23 [3] => torstaina: 00 – 23 [4] => perjantaina: 00 – 23 [5] => lauantaina: 00 – 23 [6] => sunnuntaina: 00 – 23 ) ) [estimatedDelivery] => 2022-03-09T12:30:00.000Z [cutoff] => 2022-03-06T17:18:52.683Z [distance] => 5909 [label] => Prisma Kuopio (9.3.2022 ~14:30) ) [3] => Array ( [id] => BOX2758 [address] => Array ( [street] => Pirtinkaari 28 [postalCode] => 70820 [city] => Kuopio [country] => FI [coordinate] => Array ( [latitude] => 62.828854344746 [longitude] => 27.666087775005 ) ) [name] => K-Market Pirtti Kuopio [directions] => Budbee Box sijaitsee K-Market Pirtin kassojen vieressä. [openingHours] => Array ( [periods] => Array ( [0] => Array ( [open] => Array ( [day] => MONDAY [time] => 08:00 ) [close] => Array ( [day] => MONDAY [time] => 21:00 ) ) [1] => Array ( [open] => Array ( [day] => TUESDAY [time] => 08:00 ) [close] => Array ( [day] => TUESDAY [time] => 21:00 ) ) [2] => Array ( [open] => Array ( [day] => WEDNESDAY [time] => 08:00 ) [close] => Array ( [day] => WEDNESDAY [time] => 21:00 ) ) [3] => Array ( [open] => Array ( [day] => THURSDAY [time] => 08:00 ) [close] => Array ( [day] => THURSDAY [time] => 21:00 ) ) [4] => Array ( [open] => Array ( [day] => FRIDAY [time] => 08:00 ) [close] => Array ( [day] => FRIDAY [time] => 21:00 ) ) [5] => Array ( [open] => Array ( [day] => SATURDAY [time] => 09:00 ) [close] => Array ( [day] => SATURDAY [time] => 21:00 ) ) [6] => Array ( [open] => Array ( [day] => SUNDAY [time] => 11:00 ) [close] => Array ( [day] => SUNDAY [time] => 20:00 ) ) ) [weekdayText] => Array ( [0] => maanantaina: 08 – 21 [1] => tiistaina: 08 – 21 [2] => keskiviikkona: 08 – 21 [3] => torstaina: 08 – 21 [4] => perjantaina: 08 – 21 [5] => lauantaina: 09 – 21 [6] => sunnuntaina: 11 – 20 ) ) [estimatedDelivery] => 2022-03-09T13:30:00.000Z [cutoff] => 2022-03-06T17:18:52.692Z [distance] => 6631 [label] => K-Market Pirtti Kuopio (9.3.2022 ~15:30) ) [4] => Array ( [id] => BOX2698 [address] => Array ( [street] => Matkuksentie 60 [postalCode] => 70800 [city] => Kuopio [country] => FI [coordinate] => Array ( [latitude] => 62.823111188762 [longitude] => 27.604285187022 ) ) [name] => H&M Matkus Kuopio [directions] => Budbee Box sijaitsee kauppakeskus Matkuksen H&M-myymälässä. Löydät Boxin naistenosastolta, liukuportaiden vierestä myymälän pohjakerroksessa. [openingHours] => Array ( [periods] => Array ( [0] => Array ( [open] => Array ( [day] => MONDAY [time] => 10:00 ) [close] => Array ( [day] => MONDAY [time] => 20:00 ) ) [1] => Array ( [open] => Array ( [day] => TUESDAY [time] => 10:00 ) [close] => Array ( [day] => TUESDAY [time] => 20:00 ) ) [2] => Array ( [open] => Array ( [day] => WEDNESDAY [time] => 10:00 ) [close] => Array ( [day] => WEDNESDAY [time] => 20:00 ) ) [3] => Array ( [open] => Array ( [day] => THURSDAY [time] => 10:00 ) [close] => Array ( [day] => THURSDAY [time] => 20:00 ) ) [4] => Array ( [open] => Array ( [day] => FRIDAY [time] => 10:00 ) [close] => Array ( [day] => FRIDAY [time] => 20:00 ) ) [5] => Array ( [open] => Array ( [day] => SATURDAY [time] => 10:00 ) [close] => Array ( [day] => SATURDAY [time] => 19:00 ) ) [6] => Array ( [open] => Array ( [day] => SUNDAY [time] => 11:00 ) [close] => Array ( [day] => SUNDAY [time] => 18:00 ) ) ) [weekdayText] => Array ( [0] => maanantaina: 10 – 20 [1] => tiistaina: 10 – 20 [2] => keskiviikkona: 10 – 20 [3] => torstaina: 10 – 20 [4] => perjantaina: 10 – 20 [5] => lauantaina: 10 – 19 [6] => sunnuntaina: 11 – 18 ) ) [estimatedDelivery] => 2022-03-09T13:00:00.000Z [cutoff] => 2022-03-06T17:18:52.700Z [distance] => 9316 [label] => H&M Matkus Kuopio (9.3.2022 ~15:00) ) ) )
Basically I know I need a nested foreach loop for street, but why does the id not return anything?
I can see that this code results in five separate option blocks but they are all empty (even the ID).
<option value="">
<!-- -->
</option>
<option value="">
<!-- -->
</option>
<option value="">
<!-- -->
</option>
<option value="">
<!-- -->
</option>
<option value="">
<!-- -->
</option>
What am I doing wrong with this array?
I've this array, that i want to reoder indexes of "Mer" elements.
Array
(
[Tennis 1] => Array
(
[IntervalTime] => Array
(
[Mer] => Array
(
[3] => 09:00
[4] => 10:00
[5] => 11:00
[6] => 12:00
[7] => 13:00
[8] => 14:00
[9] => 15:00
[10] => 16:00
[11] => 17:00
[12] => 18:00
)
)
)
[Padel 1] => Array
(
[IntervalTime] => Array
(
[Mer] => Array
(
[0] => 05:00
[1] => 06:00
[2] => 07:00
[3] => 08:00
[4] => 09:00
[5] => 10:00
[6] => 11:00
)
)
)
)
Array
(
[Tennis 1] => Array
(
[IntervalTime] => Array
(
[Mer] => Array
(
[3] => 09:00
[4] => 10:00
[5] => 11:00
[6] => 12:00
[7] => 13:00
[8] => 14:00
[9] => 15:00
[10] => 16:00
[11] => 17:00
[12] => 18:00
)
)
)
[Padel 1] => Array
(
[IntervalTime] => Array
(
[Mer] => Array
(
[4] => 09:00
[5] => 10:00
[6] => 11:00
)
)
)
)
This array is back from
unset($DisponibilitaRoom[$room]["IntervalTime"][$Giorni[$DayOfWeekGiornoScelto]][$index]);
so i need to reorder this: $DisponibilitaRoom[$room]["IntervalTime"][$Giorni[$DayOfWeekGiornoScelto]], but something was wrong in my concept.
I've tried array_values() for this multidimensional array but that was not good.
Any idea is apprectiated.
You are correct in wanting to use array_values to reorder indexes. Based on your array structure, this should work:
$DisponibilitaRoom[$room]["IntervalTime"][$Giorni[$DayOfWeekGiornoScelto]] = array_values($DisponibilitaRoom[$room]["IntervalTime"][$Giorni[$DayOfWeekGiornoScelto]]);
The requirement is to produce a list of dates for specific days within a defined period, i.e every Thursday for May 2019 through September 2019.
Expecting the format to be:
Array
(
[0] => 2019-05-02
[1] => 2019-05-09
[2] => 2019-05-16
[3] => 2019-05-23
[4] => 2019-05-30
[5] => 2019-06-06
[6] => 2019-06-13
[7] => 2019-06-20
[8] => 2019-06-27
[9] => 2019-07-04
[10] => 2019-07-11
[11] => 2019-07-18
[12] => 2019-07-25
[13] => 2019-08-01
[14] => 2019-08-08
[15] => 2019-08-15
[16] => 2019-08-22
[17] => 2019-08-29
[18] => 2019-09-05
[19] => 2019-09-12
[20] => 2019-09-19
[21] => 2019-09-26
)
Current code is:
function getCompDates($y, $m) {
$allDates = [];
$current = strtotime("first thursday of $y-$m");
$end = strtotime("last day of $y-$m");
while ($current <= $end) {
$allDates[] = date('Y-m-d', $current);
$current = strtotime('next thursday', $current);
}
return $allDates;
}
$thursdays = [];
$thursdays_tmp = [];
for ($i = 5; $i <= 9; $i++) {
$thursdays_tmp[] = getCompDates(2019, sprintf('%02d', $i));
print_r($thursdays_tmp);
}
I really just want the $thursday array to be my result. I have added the $thursday_tmp variable for "inner" loop processing, which then finally combines back into $thursday
However, by the final run of the loop, the $thursday_tmp array looks like:
Array
(
[0] => Array
(
[0] => 2019-05-02
[1] => 2019-05-09
[2] => 2019-05-16
[3] => 2019-05-23
[4] => 2019-05-30
)
[1] => Array
(
[0] => 2019-06-06
[1] => 2019-06-13
[2] => 2019-06-20
[3] => 2019-06-27
)
[2] => Array
(
[0] => 2019-07-04
[1] => 2019-07-11
[2] => 2019-07-18
[3] => 2019-07-25
)
[3] => Array
(
[0] => 2019-08-01
[1] => 2019-08-08
[2] => 2019-08-15
[3] => 2019-08-22
[4] => 2019-08-29
)
[4] => Array
(
[0] => 2019-09-05
[1] => 2019-09-12
[2] => 2019-09-19
[3] => 2019-09-26
)
)
You were close, just change this code at the for loop to merge all the arrays into just one:
for ($i = 5; $i <= 9; $i++) {
$thursdays_tmp = array_merge($thursdays_tmp, getCompDates(2019, sprintf('%02d', $i)));
}
print_r($thursdays_tmp);
The complete code can be seen and run here: http://sandbox.onlinephpfunctions.com/code/11439d56c14229acf23ad57a07f71aa88f944040
I have this function that returns an array of years, months and days but I need to replace the days with weeks, so each month array will contain the weeks. Its not that easy.
$start_date = '2007-03-24';
$end_date = '2009-06-26';
year_month($start_date, $end_date);
//Returns an array containing the years, months and days between two dates
public function year_month($start_date, $end_date)
{
$begin = new DateTime( $start_date );
$end = new DateTime( $end_date);
$end->add(new DateInterval('P1D')); //Add 1 day to include the end date as a day
$interval = new DateInterval('P1D');
$period = new DatePeriod($begin, $interval, $end);
$aResult = array();
foreach ( $period as $dt )
{
$aResult[$dt->format('Y')][$dt->format('F')][$dt->format('j')] = $dt->format('D');
}
return $aResult;
}
Currently results in:
[2013] => Array
(
[October] => Array
(
[15] => Tue
[16] => Wed
[17] => Thu
[18] => Fri
[19] => Sat
[20] => Sun
[21] => Mon
[22] => Tue
[23] => Wed
[24] => Thu
[25] => Fri
[26] => Sat
[27] => Sun
[28] => Mon
[29] => Tue
[30] => Wed
[31] => Thu
)
[November] => Array
(
[1] => Fri
[2] => Sat
[3] => Sun
[4] => Mon
[5] => Tue
[6] => Wed
[7] => Thu
[8] => Fri
[9] => Sat
[10] => Sun
[11] => Mon
[12] => Tue
[13] => Wed
[14] => Thu
[15] => Fri
[16] => Sat
[17] => Sun
[18] => Mon
[19] => Tue
[20] => Wed
[21] => Thu
[22] => Fri
[23] => Sat
[24] => Sun
[25] => Mon
[26] => Tue
[27] => Wed
[28] => Thu
[29] => Fri
[30] => Sat
)
[December] => Array
(
I need something like this :
[2013] => Array
(
[October] => Array
(
[0] => week 1
[1] => week 2
[2] => week 3
[3] => week 4
[3] => week 5
Not sure if this is what you're wanting but, hey ho.
$start_date = '2007-03-24';
$end_date = '2009-06-26';
print_r(year_month($start_date, $end_date));
//Returns an array containing the years, months and week numbers between two dates
function year_month($start_date, $end_date)
{
$begin = new DateTime( $start_date );
$end = new DateTime( $end_date);
$end->add(new DateInterval('P1D')); //Add 1 day to include the end date as a day
$interval = new DateInterval('P1W'); //Add 1 week
$period = new DatePeriod($begin, $interval, $end);
$aResult = array();
foreach ( $period as $dt )
{
$aResult[$dt->format('Y')][$dt->format('F')][] = "Week ".$dt->format('W');
}
return $aResult;
}
Will return
Array
(
[2007] => Array
(
[March] => Array
(
[0] => Week 12
[1] => Week 13
)
[April] => Array
(
[0] => Week 14
[1] => Week 15
[2] => Week 16
[3] => Week 17
)
[May] => Array
(
[0] => Week 18
[1] => Week 19
[2] => Week 20
[3] => Week 21
)
[June] => Array
(
[0] => Week 22
[1] => Week 23
[2] => Week 24
[3] => Week 25
[4] => Week 26
)
[July] => Array
(
[0] => Week 27
[1] => Week 28
[2] => Week 29
[3] => Week 30
)
)
)
Full array
This function should do it, i use strtotime instead of the DateTime classes though
function year_month($start_date,$end_date){
$current_date = strtotime($start_date);
$end_date = strtotime($end_date);
$out=array();
while($current_date<=$end_date){
$out[date("Y",$current_date)][date("F",$current_date)][date("W",$current_date)][]=date("D",$current_date);
$current_date=strtotime("+1 days",$current_date);
}
return $out;
}
print_r(year_month("2007-03-24","2009-06-26"));
I currently have some text like this:
W. 50DateWorkSuggested breakTotalMondayTuesday11/1217:00-01:0020:30-21:157:15Wednesday12/1217:00-01:0019:00-19:457:15ThursdayFridaySaturday15/1216:00-23:0020:00-20:456:15Sunday16/1217:00-01:0021:00-21:457:15Total:28W. 51DateWorkSuggested breakTotalMonday17/1217:00-01:0019:00-19:457:15TuesdayWednesday19/1217:00-00:0021:00-21:456:15Thursday20/1223:00-07:0003:00-03:457:15Friday21/1223:00-07:0002:30-03:157:15SaturdaySundayTotal:28W. 52DateWorkSuggested breakTotalMondayTuesdayWednesdayThursdayFridaySaturdaySundayTotal:0W. 1DateWorkSuggested breakTotalMonday------Total:0 Total number of hours: 77:45 Schedule for Month: December
It originally looked different but I have removed the html tags as it was all in tables,
I now however want to spilt / explode this data so that theres one day on each line reading like:
Monday 10/12:
Tuesday 11/12: 17:00 - 01:00
Wednesday 12/12: 17:00 - 01:00
Thursday 13/12:
Friday 14/12:
Saturday: 15/12: 16:00 - 23:00
Thats an example for the first week, I have tried code like:
preg_match_all (("/Monday|Tuesday|Wednesday|Thusday|Fiday|Saturday|Sunday/"), $content, $parts );
print_r ($parts);
But not really having any luck, so any help would be appreciated,
Thanks,
Jack.
ORIGINAL CODE WITH HTML TAGS:
<body> <table border=0 class=blackborder cellpadding=2 cellspacing=2>
<tr><td><table class=blackborder width=315><tr><td><b>W. 50</b></td><td><B>Date</B></td><td><B>Work</B></td><td><B>Suggested break</B></td><td><B>Total</B></td><tr><td></tr><tr><td>Monday</tr><tr><td>Tuesday<td>11/12</td><td>17:00-01:00</td><td>20:30-21:15</td><td>7:15</td></tr><tr><td>Wednesday<td>12/12</td><td>17:00-01:00</td><td>19:00-19:45</td><td>7:15</td></tr><tr><td>Thursday</tr><tr><td>Friday</tr><tr><td>Saturday<td>15/12</td><td>16:00-23:00</td><td>20:00-20:45</td><td>6:15</td></tr><tr><td>Sunday<td>16/12</td><td>17:00-01:00</td><td>21:00-21:45</td><td>7:15</td></td></tr><tr><td>Total:</td><td></td><td></td><td></td><td>28</td></tr></table></td><td><table class=blackborder width=315><tr><td><b>W. 51</b></td><td><B>Date</B></td><td><B>Work</B></td><td><B>Suggested break</B></td><td><B>Total</B></td><tr><td></tr><tr><td>Monday<td>17/12</td><td>17:00-01:00</td><td>19:00-19:45</td><td>7:15</td></tr><tr><td>Tuesday</tr><tr><td>Wednesday<td>19/12</td><td>17:00-00:00</td><td>21:00-21:45</td><td>6:15</td></tr><tr><td>Thursday<td>20/12</td><td>23:00-07:00</td><td>03:00-03:45</td><td>7:15</td></tr><tr><td>Friday<td>21/12</td><td>23:00-07:00</td><td>02:30-03:15</td><td>7:15</td></tr><tr><td>Saturday</tr><tr><td>Sunday</td></tr><tr><td>Total:</td><td></td><td></td><td></td><td>28</td></tr></table></td></tr><tr><td><table class=blackborder width=315><tr><td><b>W. 52</b></td><td><B>Date</B></td><td><B>Work</B></td><td><B>Suggested break</B></td><td><B>Total</B></td><tr><td></tr><tr><td>Monday</tr><tr><td>Tuesday</tr><tr><td>Wednesday</tr><tr><td>Thursday</tr><tr><td>Friday</tr><tr><td>Saturday</tr><tr><td>Sunday</td></tr><tr><td>Total:</td><td></td><td></td><td></td><td>0</td></tr></table></td><td><table class=blackborder width=315><tr><td><b>W. 1</b></td><td><B>Date</B></td><td><B>Work</B></td><td><B>Suggested break</B></td><td><B>Total</B></td><tr><td></tr><tr><td>Monday</td></tr><tr><td>-</td></tr><tr><td>-</td></tr><tr><td>-</td></tr><tr><td>-</td></tr><tr><td>-</td></tr><tr><td>-</td></tr><tr><td>Total:</td><td></td><td></td><td></td><td>0</td></tr></table> </td> </tr> <tr> <td colspan=2> <b>Total number of hours:</b> 77:45<br> </td> </tr> </table> </body>
well i can get a day and time with regex
$str = 'W. 50DateWorkSuggested breakTotalMondayTuesday11/1217:00-01:0020:30-21:157:15Wednesday12/1217:00-01:0019:00-19:457:15ThursdayFridaySaturday15/1216:00-23:0020:00-20:456:15Sunday16/1217:00-01:0021:00-21:457:15Total:28W. 51DateWorkSuggested breakTotalMonday17/1217:00-01:0019:00-19:457:15TuesdayWednesday19/1217:00-00:0021:00-21:456:15Thursday20/1223:00-07:0003:00-03:457:15Friday21/1223:00-07:0002:30-03:157:15SaturdaySundayTotal:28W. 52DateWorkSuggested breakTotalMondayTuesdayWednesdayThursdayFridaySaturdaySundayTotal:0W. 1DateWorkSuggested breakTotalMonday------Total:0 Total number of hours: 77:45 Schedule for Month: December';
$ptr = "/(?P<day>:Monday|Tuesday|Wednesday|Thusday|Fiday|Saturday|Sunday?)(?P<time>([0-9:\/\- ]?)+)/";
preg_match_all($ptr, $str, $data);
echo '<pre>';
print_r($data);
echo '</pre>';
the output will be like this
Array
(
[0] => Array
(
[0] => Tuesday11/1217:00-01:0020:30-21:157:15
[1] => Wednesday12/1217:00-01:0019:00-19:457:15
[2] => Saturday15/1216:00-23:0020:00-20:456:15
[3] => Sunday16/1217:00-01:0021:00-21:457:15
[4] => Tuesday
[5] => Wednesday19/1217:00-00:0021:00-21:456:15
[6] => Saturday
[7] => Sunday
[8] => Tuesday
[9] => Wednesday
[10] => Saturday
[11] => Sunday
)
[day] => Array
(
[0] => Tuesday
[1] => Wednesday
[2] => Saturday
[3] => Sunday
[4] => Tuesday
[5] => Wednesday
[6] => Saturday
[7] => Sunday
[8] => Tuesday
[9] => Wednesday
[10] => Saturday
[11] => Sunday
)
[1] => Array
(
[0] => Tuesday
[1] => Wednesday
[2] => Saturday
[3] => Sunday
[4] => Tuesday
[5] => Wednesday
[6] => Saturday
[7] => Sunday
[8] => Tuesday
[9] => Wednesday
[10] => Saturday
[11] => Sunday
)
[time] => Array
(
[0] => 11/1217:00-01:0020:30-21:157:15
[1] => 12/1217:00-01:0019:00-19:457:15
[2] => 15/1216:00-23:0020:00-20:456:15
[3] => 16/1217:00-01:0021:00-21:457:15
[4] =>
[5] => 19/1217:00-00:0021:00-21:456:15
[6] =>
[7] =>
[8] =>
[9] =>
[10] =>
[11] =>
)
[2] => Array
(
[0] => 11/1217:00-01:0020:30-21:157:15
[1] => 12/1217:00-01:0019:00-19:457:15
[2] => 15/1216:00-23:0020:00-20:456:15
[3] => 16/1217:00-01:0021:00-21:457:15
[4] =>
[5] => 19/1217:00-00:0021:00-21:456:15
[6] =>
[7] =>
[8] =>
[9] =>
[10] =>
[11] =>
)
[3] => Array
(
[0] =>
[1] =>
[2] =>
[3] =>
[4] =>
[5] =>
[6] =>
[7] =>
[8] =>
[9] =>
[10] =>
[11] =>
)
)
then you can loop to make a data nice ;)