Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/241.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php数组显示多数组的第一个值_Php - Fatal编程技术网

Php数组显示多数组的第一个值

Php数组显示多数组的第一个值,php,Php,我知道这是一个简单的问题,但我想不出来 如何仅显示此数组中的第一个值(未上载文件)?阵列可以不同!所以$test[fileUploadFileErrorNoFile]不是解决方案 $test = Array ( [fileUploadFileErrorNoFile] => File was not uploaded [fileMimeTypeNotReadable] => File is not readable or does not exist

我知道这是一个简单的问题,但我想不出来

如何仅显示此数组中的第一个值(未上载文件)?阵列可以不同!所以$test[fileUploadFileErrorNoFile]不是解决方案

$test = Array ( [fileUploadFileErrorNoFile] => File was not uploaded 
                [fileMimeTypeNotReadable] => File is not readable or does not exist 
                [fileIsImageNotReadable] => File is not readable or does not exist 
                [fileImageSizeNotReadable] => File is not readable or does not exist 
            )
试试这个:

$test = Array (   "[fileIsImageNotReadable] => File is not readable or does not exist", "[fileImageSizeNotReadable] => File is not readable or does not exist" );


echo $test[0]; // 0 == the first value

您的阵列是这样的吗

$test = Array (
           Array(
         fileUploadFileErrorNoFile => 'File was not uploaded' ,
         fileMimeTypeNotReadable => 'File is not readable or does not exist',
         fileIsImageNotReadable => 'File is not readable or does not exist', 
         fileImageSizeNotReadable => 'File is not readable or does not exist'
         )
    );
那么答案是:

echo $test[0][fileUploadFileErrorNoFile];

数组_值($test)[0]?数组_pop(数组_反向($array))@Daniel1147就是这样!谢谢如果阵列不可用,此解决方案将给您一个错误empty@MarkoPaju是对的。除了OP的数组看起来和你的示例不一样,除了OP的数组和你的示例不一样