**php two-dimensional array time-duration assignment

Source: Internet
Author: User

php Two-dimensional array traversal assignment

My personal wording in the project:

Traversing a two-dimensional array
foreach ($tmp _array as $key = + $value) {
URL for dynamically generated pictures
$attach _url = $this->qiniu_utils->get_download_url ($tmp _array[$key [' attach_save_name '], ' 7vih5p.com1.z0.glb.clouddn.com ', ' PRIVATE ');
Assignment URL
$tmp _array[$key] [' attach_save_url '] = $attach _url;
}
$result [' feed_img_ids '] = $tmp _array;

---------------------------------------------------------------------------the following is the online reference answer

Q:

$arr = Array (' One ' =>array (' name ' = ' = ' Zhang San ', ' age ' = ' ~ ', ' sex ' = ' male '),
' =>array ' (' name ' = ' John Doe ', ' age ' = ' ', ' sex ' = ' female '),
' Three ' =>array (' name ' = ' Harry ', ' age ' = ' + ', ' sex ' = ' man '),
' Four ' =>array (' name ' = ' Zhao Liu ', ' age ' = ' n ', ' sex ' = ' female ');

foreach ($arr as $key = = $value) {
foreach ($value as $key 2=> $value 2) {
$arr [$ey] [$value] [$key 2][' age ']= 55;

}
}

Print_r ($arr);

How do I assign a new value to age?

A:
foreach ($arr as $key = = $value) {
$arr [$key] [' Age ']=55
}
Look at your needs, it's all right.

Reference 2:
PHP Traversal array assignment why not?

Http://www.oschina.net/question/1434721_149652?sort=default&p=2#answers

**php two-dimensional array time-duration assignment

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.