There is a download to the array of images in base64 format.

$base64 = 'data:image/' . $type . ';base64,'. base64_encode($data); $data['numOne'] = strval($base64); 

And there is a download to the array of images in the format of the link.

 $data['numOne'] = file_create_url($file->uri); 

Both return a string.

But in the first example, an error occurs. Moreover, if you insert the finished result in the form of a line in the first example, then everything works.

illegal string offset


I noticed that I use one and I need a variable.

    1 answer 1

    You form a string of pictures

     $base64 = 'data:image/' . $type . ';base64,'. base64_encode($data); 

    from this line, we can assume that $data is the string content of your image, and not an array. But in the next line, you refer to $data as an array

     $data['numOne'] = ...; 

    which causes an error

    illegal string offset

    since the string can also be accessed as an array, but the index 'numOne' is not in it