Questions about array values

Source: Internet
Author: User
Questions about array values! Digest [md5] & gt; b68d88dbdfc9d0af2 questions about array values!
PHP code
  // Known array $ info = array (); // outputs print_r ($ info ); // result Array ([0] => Array ([name] => 8.gif [md5] => token [saveName] => 20120602080557_452.gif [size] => 1 [type] => image/gif [originalHeight] => 39 [originalWidth] => 31) [1] => Array ([name] => 9.gif [md5] => 4988f85ebebf82f56d70eeaf39a67016 [saveName] => 20120602080557_776.gif [size] => 2 [type] => image/gif [originalHeight] => 39 [originalWidth] => 31 ))


How can I retrieve the corresponding saveName value?

------ Solution --------------------
PHP code
Foreach ($ info as $ value) {foreach ($ value as $ getValue) {echo $ getValue ['savename'];}
------ Solution --------------------
Foreach ($ info as $ v) $ temp [] = $ v ['savename'];
Print_r ($ temp );
------ Solution --------------------
It seems that name is similar to a unique field and you want to retrieve the savename field corresponding to name. In this case, you need to receive the name field value you have given. when you submit it in the post form.

Two-dimensional array. A foreach statement is enough.

PHP code
$ A = Array ('name' => '8.gif ', 'md5' => 'clerk', 'savename' => '20120602080557_452.gif', 'size' => 1, 'type' => 'image/gif ', 'ininalheight' => 39, 'originalwidth' => 31), Array ('name' => '9.gif ', 'md5' => '4988f85ebebf82f56d70eeaf39a67016 ', 'savename' => '20120602080557_776.gif', 'size' => 2, 'type' => 'image/GIF ', 'originalheight' => 39, 'originalwidth' => 31,); foreach ($ a as $ k => $ v) {if ($ v ['name'] ===$ _ POST ['yourname']) {// __post+'yourname'{'8.gif ', $ v else echo' $ v ['will be output ['. 'savename '. '] = '. $ v ['savename'].'
';}}?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.