In Laravel 8 framework I have my array in $getDates which get dates depend of week days.
**
$start = '2020-12-12';
$end = '2021-02-15';
$getDates=[];
$monday=1;
$tuesday=0;
$wednesday=1;
$thursday=0;
$friday=0;
$saturday=0;
$sunday=0;
$start = new DateTime($start);
$end = new DateTime($end);
while($start <= $end ){
$time_stamp = strtotime($start->format('Y-m-d'));
$newdate = date ( 'd M Y D' , $time_stamp ); ;
$week = date('l', $time_stamp);
if ($sunday==1) {
if ($week == 'Sunday')
$getDates[]=[$newdate,'0',''];
}
if ($monday==1) {
if ($week == 'Monday')
$getDates[]=[$newdate,'0',''];
}
if ($tuesday==1) {
if ($week == 'Tuesday')
$getDates[]=[$newdate,'0',''];
}
if ($wednesday==1) {
if ($week == 'Wednesday')
$getDates[]=[$newdate,'0',''];
}
if ($thursday==1) {
if ($week == 'Thursday')
$getDates[]=[$newdate,'0',''];
}
if ($friday==1) {
if ($week == 'Friday')
$getDates[]=[$newdate,'0',''];
}
if ($saturday==1) {
if ($week == 'Saturday')
$getDates[]=[$newdate,'0',''];
}
$start->modify('+1 day');
}
$getDates_json=json_encode($getDates); //make json from array
<form method="post" action="{{route('add_new_course')}}">
@csrf
<input type="hidden" name="schedule" value=<?php echo $_POST['schedule'] ?> />
<p align="center">
<input type="submit" class="btn btn-success" value="CREATE COURSE">
<br>
<a href="/courses" class="btn btn-info">Return</a>
</p>
</form>
**
// And I try get JSON format to $getDates_json, and its looks
"[["14 Dec 2020 Mon","0",""],["16 Dec 2020 Wed","0",""],["21 Dec 2020 Mon","0",""],["23 Dec 2020 Wed","0",""],["28 Dec 2020 Mon","0",""],["30 Dec 2020 Wed","0",""],["04 Jan 2021 Mon","0",""],["06 Jan 2021 Wed","0",""],["11 Jan 2021 Mon","0",""],["13 Jan 2021 Wed","0",""],["18 Jan 2021 Mon","0",""],["20 Jan 2021 Wed","0",""],["25 Jan 2021 Mon","0",""],["27 Jan 2021 Wed","0",""],["01 Feb 2021 Mon","0",""],["03 Feb 2021 Wed","0",""],["08 Feb 2021 Mon","0",""],["10 Feb 2021 Wed","0",""],["15 Feb 2021 Mon","0",""]]"
and when I send it by POST method I get value looks
[["14
If some body know how I can send this JSON via POST for INSERT to MySQL DB? In the end, I need sometimes update information inside JSON and put it back to DB.
question from:
https://stackoverflow.com/questions/65930638/have-problems-to-send-json-via-post-method-in-php