I have the following array that I need to extract a value from. How would I go about doing this?

I'm used to doing something like echo $row[0]; to get information out of an array...but unable to do so with this guy. I'm trying to get [file_copy] => 1207057919.jpg from it.

(
    [number_of_files] => 1
    [names_array] => Array
        (
            [0] => Copy of buffv19.jpg
            [1] => 
            [2] => 
        )

[tmp_names_array] => Array
    (
        [0] => /tmp/phpUduoib
        [1] => 
        [2] => 
    )

[error_array] => Array
    (
        [0] => 0
        [1] => 4
        [2] => 4
    )

[wrong_extensions] => 0
[bad_filenames] => 0
[the_file] => Copy of buffv19.jpg
[the_temp_file] => /tmp/phpUduoib
[upload_dir] => /www/homeownerhomesales.com/htdocs/files/
[replace] => y
[do_filename_check] => n
[max_length_filename] => 100
[extensions] => Array
    (
        [0] => .jpeg
        [1] => .jpg
        [2] => .gif
        [3] => .png
        [4] => .zip
    )

[ext_string] => 
[language] => en
[http_error] => 
[rename_file] => 1
[file_copy] => 1207057919.jpg
[message] => Array
    (
        [0] => File: Copy of buffv19.jpg successfully uploaded!
        [1] => The uploaded file is renamed to 1207057919.jpg.
    )

[create_directory] => 1
)

    Your array has got a name
    lets say it is $myarr

    Think you have a temporary blackout,
    because you know these things, rodneykm

    As far as I can see this should work:

    echo $myarr['file_copy']; 

    And subarray:

    foreach( $myarr['extensions'] AS $ext){
        echo $ext;
    } 
    foreach( $myarr['error_array'] AS $errnum){
        if($errnum > 0){
             exit( 'ERROR Number: ' . $errnum );
        }
    } 

    regars 🙂
    your halojoy

      Write a Reply...