You are here: Re: accessing array data inside of an array « PHP Programming Language « IT news, forums, messages
Re: accessing array data inside of an array

Posted by bill on 11/18/07 15:47

ZeldorBlat wrote:
> On Nov 18, 10:13 am, bill <nob...@spamcop.net> wrote:
>> I want to extract the name of the photo uploaded.
>>
>> print_r of $_FILES yields:
>> Files: Array ( [picture] => Array ( [name] =>
>> DSC_1802-saoirse-riona.jpg [type] => image/jpeg [tmp_name] =>
>> /tmp/phpJTspHZ [error] => 0 [size] => 76096 ) )
>>
>> so we have an array with one element, picture, that contains an
>> array with an index, name, with a value of DSC_1802-saoirse-riona.jpg
>>
>> I get the correct value when I:
>> $pic_name = $_FILES['picture']['name'];
>> echo $pic_name
>>
>> however when I use:
>>
>> echo "<br />pic_name = $_FILES[picture][name]";
>>
>> I get:
>> pic_name = Array[name]
>>
>> Why does the echo with the array reference not work while the
>> assignment does ?
>>
>> bill
>
> Put quotes around your array keys:
>
> $_FILES['picture']['name']

That, unfortunately, generates the dreaded:
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE,
expecting T_STRING or T_VARIABLE or T_NUM_STRING in...

bill

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация