I am an absolute beginner of laravel.
I am dealing with the error **"preg\_replace(): Parameter mismatch, pattern is a string while replacement is an array"** when I try to update an array of data.

Does anyone know a way to solve the error?
If you need more information, please leave your comments.

Any advice would be appreciated. Thanks in advance!

**LogsController.php**

```
public function update(CreateLogRequest $request, $course_id){

    $count = count($request->input('weeks'));
    $input = $request->all();
    $logs = array();

    for ($i = 0; $i < $count; $i++){
        if($input['weeks'][$i]){
            array_push($logs, array(
                'user_id' => \Auth::user()->id,
                'course_id' => $course_id,
                'weeks' => $i + 1,
                'work_description' => $input['work_description'][$i],
                'instructor_comments' => $input['instructor_comments'][$i],
                'status' => $input['status'][$i],
                'created_at' => Carbon::now(),
                'updated_at' => Carbon::now(),
            ));
        }
    }
    $log->update($logs);
    return redirect('/student/home');
}

```

When I put a code dd($logs), the result is below.

```
array:2 [▼
  0 => array:8 [▼
  "user_id" => "1"
  "course_id" => "39"
  "weeks" => 1
  "work_description" => "fadfad"
  "instructor_comments" => "fdasfda"
  "status" => "accepted"
  "created_at" => Carbon {#219 ▶}
  "updated_at" => Carbon {#212 ▶}
]
 1 => array:8 [▼
   "user_id" => "1"
   "course_id" => "39"
   "weeks" => 2
   "work_description" => "fadsfad"
   "instructor_comments" => "fdasfdasfad"
   "status" => "accepted"
   "created_at" => Carbon {#218 ▶}
   "updated_at" => Carbon {#222 ▶}
 ]
]  

```

**Log\_edit.blade.php**

```
{!! Form::hidden('course_id', $course->id) !!}
    @foreach($logs as $log)
        <tbody>
        <tr>
            <td>
                {{ $log->weeks }}
                {!! Form::hidden('weeks[]', $log->weeks) !!}
            </td>

            <td> {!! Form::textarea('work_description[]', $log->work_description) !!}  </td>

            <td> {!! Form::textarea('instructor_comments[]', $jlog->instructor_comments) !!} </td>

            <td> {!! Form::select('status[]',
                        array('accepted' => 'accepted',
                              'pending' => 'pending',
                              'declined' => 'declined',
                      ), $log->status) !!}
            </td>
        </tr>
        @endforeach

        </tbody>

```