When using backslash n you need "" instead of '' to parse it as a newline, and not plain text
$error = implode("\n", $error);
//or
$error = implode(PHP_EOL, $error);
I'm trying to implode a new line in between my array variables but so far nothing have worked. Does anyone know the solution to my problem? `` public function destroy($id,Request $request) { //decline student $user = User::findOrFail($id);
$error = array('reason' => 'Reason for rejection:');
if (isset($request['reason1'])) {
$reason1= $request->input('reason1');
$error = array_add($error, 'reason1', $reason1);
}
if (isset($request['reason2'])) {
$reason2= $request->input('reason2');
$error = array_add($error, 'reason2', $reason2);
}
if (isset($request['reason3'])) {
$reason3= $request->input('reason3');
$error = array_add($error, 'reason3', $reason3);
}
if (isset($request['reason4'])) {
$reason4= $request->input('reason4');
$error = array_add($error, 'reason4', $reason4);
}
if (isset($request['reason5'])) {
$reason5= $request->input('reason5');
$error = array_add($error, 'reason5', $reason5);
}
if (isset($request['reason6'])) {
$reason6= $request->input('reason6');
$error = array_add($error, 'reason6', $reason6);
}
if (isset($request['reason7'])) {
$reason7= $request->input('reason7');
$error = array_add($error, 'reason7', $reason7);
}
$error = implode('\n', $error);
if(!$user){
$request->session()->flash('error','You can not delete this the user');
return redirect(route('admin.users.index'));
}
$url = URL::signedRoute('user.profile' , ['id'=> $id]);
$updatedata =[
'body'=> 'Your enrolment application has been denied',
'error'=> $error,
'message'=> 'You are allowed to update your form',
'url'=> $url,
'thankyou'=> 'You have 3 days to update your form'
];
Notification::send($user, new UpdateForm($updatedata));
$request->session()->flash('success','You have deleted the user');
return redirect(route('admin.users.index'));
}
When using backslash n you need "" instead of '' to parse it as a newline, and not plain text
$error = implode("\n", $error);
//or
$error = implode(PHP_EOL, $error);
Please or to participate in this conversation.