如何从关联数组PHP中获取单个值


How to get a single value from an associative array PHP

当I代码=>

if((isset($filename1))){
    print_r(array_values($filename1));
    $file_name=$filename1['file_name'];
    echo $file_name." this is file_name<br>";
    echo $filename1['file_name']."This isdirectly from the array <br>";
    }

我得到以下输出和错误=>

Array ( [0] => Array ( [file_name] => uygun10.pgn [file_type] => application/x-chess-pgn [file_path] => D:/wamp/www/proje/uploads/ [full_path] => D:/wamp/www/proje/uploads/uygun10.pgn [raw_name] => uygun10 [orig_name] => uygun.pgn [client_name] => uygun.pgn [file_ext] => .pgn [file_size] => 0.48 [is_image] => [image_width] => [image_height] => [image_type] => [image_size_str] => ) )
A PHP Error was encountered
Severity: Notice
Message: Undefined index: file_name
Filename: controllers/Hesaplama.php
Line Number: 58
Backtrace:
File: D:'wamp'www'proje'application'controllers'Hesaplama.php
Line: 58
Function: _error_handler
File: D:'wamp'www'proje'application'controllers'Hesaplama.php
Line: 263
Function: pgn_oku
File: D:'wamp'www'proje'application'controllers'Welcome.php
Line: 28
Function: pozisyon_tutma
File: D:'wamp'www'proje'index.php
Line: 292
Function: require_once
this is file_name
A PHP Error was encountered
Severity: Notice
Message: Undefined index: file_name
Filename: controllers/Hesaplama.php
Line Number: 60
Backtrace:
File: D:'wamp'www'proje'application'controllers'Hesaplama.php
Line: 60
Function: _error_handler
File: D:'wamp'www'proje'application'controllers'Hesaplama.php
Line: 263
Function: pgn_oku
File: D:'wamp'www'proje'application'controllers'Welcome.php
Line: 28
Function: pozisyon_tutma
File: D:'wamp'www'proje'index.php
Line: 292
Function: require_once

当我修改代码如下=>

if((isset($filename1))){
print_r(array_values($filename1));
$file_name=$filename1[0]['file_name'];
echo $file_name." this is file_name<br>";
echo $filename1[0]['file_name']."this is directly from the array <br>";
}

我得到以下输出和错误=>

Array ( [0] => Array ( [file_name] => uygun11.pgn [file_type] => application/x-chess-pgn [file_path] => D:/wamp/www/proje/uploads/ [full_path] => D:/wamp/www/proje/uploads/uygun11.pgn [raw_name] => uygun11 [orig_name] => uygun.pgn [client_name] => uygun.pgn [file_ext] => .pgn [file_size] => 0.48 [is_image] => [image_width] => [image_height] => [image_type] => [image_size_str] => ) )
A PHP Error was encountered
Severity: Notice
Message: Undefined offset: 0
Filename: controllers/Hesaplama.php
Line Number: 58
Backtrace:
File: D:'wamp'www'proje'application'controllers'Hesaplama.php
Line: 58
Function: _error_handler
File: D:'wamp'www'proje'application'controllers'Hesaplama.php
Line: 263
Function: pgn_oku
File: D:'wamp'www'proje'application'controllers'Welcome.php
Line: 28
Function: pozisyon_tutma
File: D:'wamp'www'proje'index.php
Line: 292
Function: require_once
this is file_name
A PHP Error was encountered
Severity: Notice
Message: Undefined offset: 0
Filename: controllers/Hesaplama.php
Line Number: 60
Backtrace:
File: D:'wamp'www'proje'application'controllers'Hesaplama.php
Line: 60
Function: _error_handler
File: D:'wamp'www'proje'application'controllers'Hesaplama.php
Line: 263
Function: pgn_oku
File: D:'wamp'www'proje'application'controllers'Welcome.php
Line: 28
Function: pozisyon_tutma
File: D:'wamp'www'proje'index.php
Line: 292
Function: require_once

我如何可能到达数组$filename1…中的单个项目。。。?感谢所有

我只能用下面的代码=>恢复单个值

$filename2= $this->session->flashdata('item');
$filename1= $filename2['upload_data']['file_name'];

在另一个页面中使用以下代码创建会话=>

else { 
            $data = array('upload_data' => $this->upload->data()); 
            $this->load->view('Upload_success', $data); 
         } 
            $this->session->set_flashdata('item', $data);
      }

感谢所有响应者。。。