samedi 13 mars 2021

How would one sent a PHP array to email/sms and maintain the format of the text in the array?

I have this array

array:8 [▼
  0 => "http://bheng.test/baby/Norden?code=rithys4k"
  1 => "http://bheng.test/baby/Mila?code=soriy4"
  2 => "http://bheng.test/baby/tyty?code="
  3 => "http://bheng.test/baby/?code="
  4 => "http://bheng.test/baby/Beverly Hills?code="
  5 => "http://bheng.test/baby/hunter?code=99"
  6 => "http://bheng.test/baby/Lee?code=yoloMVIS"
  7 => "http://bheng.test/baby/Cheat?code="
]

I'm trying to sent this list off via SMS

I did this : adding my <pre> tag around my print_r

public function report(){


    $babies = Baby::all(); 
    $adminLinks = [];
    foreach ($babies as $i => $baby) {
        $adminLinks[$i] = env('APP_URL').'/baby/'.$baby->babyName.'?code='.$baby->readOnlyCode;
        
    }

    // dd($adminLinks);

    $message = '<pre>'.print_r($adminLinks).'</pre>'; ///SEND DATA 

    $sent = Mail::raw($message, function ($message) {
        $message->from(env('MAIL_FROM'));
        $message->to(env('LONG_PHONE'))->subject('đŸŒ >>');
    });

    if($sent) {
        return "SENT"; 
    }

}

I kept getting

enter image description here


If I don't so print_r(), I will get get

enter image description here


If I do json_encode, I'm closed. BUT it messed up my format.

enter image description here

How would one sent an array to email/sms and maintain the format of the text in the array ?

More tries

$message = $adminLinks;
$message = json_encode($adminLinks);
$message = json_encode($adminLinks, TRUE);
$message = json_encode($adminLinks, FALSE);
$message = '<pre>'.$adminLinks.'</pre>'; ///SEND DATA 
$message = implode('<br>',$adminLinks);
$message = implode('\n',$adminLinks);


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire