Q:

detect empty value in array and set it to ''

I am using exif_read_data to store data for an image in an array.
It reads jpeg files from a directory and not every image file has the same exact exif data, some files may have ExposureTime and some may not.
$exif = array();
$exif = exif_read_data('path/to/file');

$file_info = array(
 'FocalLength' => $exif['FocalLength'],
 'ExposureTime' => $exif['ExposureTime'],
 'FNumber' => $exif['FNumber']
);

Not every image may have focallength, exposuretime and fnumber, so it will display undefined index errors.
Is it possible to detect empty index's and just put '' in place of it, so it'd look like this (if there was no exposuretime and fnumber for that image):
$file_info = array(
 'FocalLength' => $exif['FocalLength'],
 'ExposureTime' => '',
 'FNumber' => ''
);

A:

Simply use the array union operator + to add values to an array if and only if the keys don't exist yet:
$exif = exif_read_data('path/to/file');
$exif += array(
    'FocalLength'  => null,
    'ExposureTime' => null,
    'FNumber'      => null
);

You should also use null rather than empty strings for "no value" values.

