Using both the array key and a passed-in value to modify each element value : Associate Array « Data Structure « PHP

PHP
1. Chart
2. Class
3. Components
4. Cookie Session
5. Data Structure
6. Data Type
7. Date
8. Design Patterns
9. Development
10. DNS
11. Email
12. File Directory
13. Form
14. Functions
15. Graphics Image
16. HTML
17. Language Basics
18. Login Authentication
19. Math
20. MySQL Database
21. Network
22. Operator
23. PDF
24. Reflection
25. Statement
26. String
27. Utility Function
28. Web Services SOAP WSDL
29. XML
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
PHP » Data Structure » Associate Array 
Using both the array key and a passed-in value to modify each element value
 
<?php 
function change(&$element, $key, $mark) { 
    $element = "$mark$key$mark, the $element"



$dogs = array('A' => 'C''B' => 'D''X' => 'Z')
array_display($dogs, TRUE)

array_walk($dogs, 'change', '*')
array_display($dogs, TRUE)
?>
  
  
Related examples in the same category
1. Use foreach, while and list to loop through associate array
2. Sort associate array
3. array_key_exists
4. array_values: Return all the values of an array
5. array_keys: Return all the keys of an array
6. Arrays Using Associative Array Notation
7. Reference the assiciate array element
8. foreach statement is used to loop through an associative array
9. Associative Arrays
10. Looping Through an Associative Array with foreach
11. key: Fetch a key from an associative array
12. print_r: output associate array
13. array_intersect_assoc: Computes the intersection of arrays with additional index check
14. An array called $computers with numeric and string keys
15. An array called $vegetables with string keys
16. Argument Swapping
17. Array to object
18. Assigning and Comparing
19. Building an array of defaults
20. Creates an array with keys 'a', 'b' and 'c with values of 1, 2 and 3 as well as keys 0, 1 and 2 with values 'a', 'b', and 'c'
21. Creating Arrays
22. Creates an array that assigns keys 1 through 7 to the days of the week.
23. Creating a multidimensional array
24. Creating an associative array of shapes
25. Obtaining Array Keys and Values
26. Obtaining Array Keys with a Given Value
27. One-based array index
28. Displaying one value from an array
29. Using Variable Variables to Create Associations
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.