Php array value transfer call and address transfer call

Source: Internet
Author: User
Php array value transfer call and address transfer call

  1. Public class ArrayTest {

  2. Public static void main (String [] args ){
  3. Map [] maparray = new Map [3];
  4. For (int I = 0; I <maparray. length; I ++ ){
  5. Map Map = new HashMap ();
  6. Map. put ("a", I + "_ ajkcz ");
  7. Map. put ("c", "werq _" + I );
  8. Maparray [I] = map;
  9. }
  10. System. out. println ("++ ");
  11. For (int I = 0; I <maparray. length; I ++ ){
  12. Map Map = maparray [I];
  13. Iterator it = map. keySet (). iterator ();
  14. While (it. hasNext ()){
  15. String key = (String) it. next ();
  16. System. out. println (key + "\ t" + map. get (key ));
  17. }
  18. }
  19. System. out. println ("++ ");
  20. New ArrayCharge (). printAndChangeArray (maparray );
  21. System. out. println ("++ ");
  22. For (int I = 0; I <maparray. length; I ++ ){
  23. Map Map = maparray [I];
  24. Iterator it = map. keySet (). iterator ();
  25. While (it. hasNext ()){
  26. String key = (String) it. next ();
  27. System. out. println (key + "\ t" + map. get (key ));
  28. }
  29. }
  30. }
  31. }

  32. Class ArrayCharge {

  33. Public void printAndChangeArray (Map [] maparray ){
  34. For (int I = 0; I <maparray. length; I ++ ){
  35. Map Map = maparray [I];
  36. Map. put ("a", I + "________");
  37. }
  38. For (int I = 0; I <maparray. length; I ++ ){
  39. Map Map = maparray [I];
  40. Iterator it = map. keySet (). iterator ();
  41. While (it. hasNext ()){
  42. String key = (String) it. next ();
  43. System. out. println (key + "\ t" + map. get (key ));
  44. }
  45. }
  46. }
  47. }

Console output result:

  1. $ Arraytest = array ();
  2. For ($ I = 0; $ I <3; $ I ++ ){
  3. $ Child = array ();
  4. $ Child ['keystr'] = 'key'. $ I;
  5. $ Child ['valuestr'] = 'value'. $ I;
  6. $ Arraytest [] = $ child;
  7. }
  8. Print_r ($ arraytest );
  9. Print_r ("++ ");
  10. For ($ I = 0; $ I $ Child = $ arraytest [$ I];
  11. $ Child ['valuestr'] = "_________". $ I;
  12. }
  13. Print_r ($ arraytest );
  14. Print_r ("++ ");
  15. ?>

Console output:

  1. $ Arraytest = array ();
  2. For ($ I = 0; $ I <3; $ I ++ ){
  3. $ Child = array ();
  4. $ Child ['keystr'] = 'key'. $ I;
  5. $ Child ['valuestr'] = 'value'. $ I;
  6. $ Arraytest [] = $ child;
  7. }
  8. Print_r ($ arraytest );
  9. Print_r ("++ ");
  10. For ($ I = 0; $ I $ Child = & $ arraytest [$ I]; // note that a pointer symbol is added here to indicate that the address is called.
  11. $ Child ['valuestr'] = "_________". $ I;
  12. }
  13. Print_r ($ arraytest );
  14. Print_r ("++ ");
  15. ?>

Console output:

Array ([0] => Array ([keystr] => key0 [valuestr] => value0) [1] => Array ([keystr] => key1 [valuestr] => value1) [2] => Array ([keystr] => key2 [valuestr] => value2 )) ++ Array ([0] => Array ([keystr] => key0 [valuestr] => _________ 0) [1] => Array ([keystr] => key1 [valuestr] => _________ 1) [2] => Array ([keystr] => key2 [valuestr] => _________ 2 )) ++

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.