Skip to content

Instantly share code, notes, and snippets.

@vijaycs85
Last active August 29, 2015 14:17
Show Gist options
  • Save vijaycs85/0a51bd0920b641aba819 to your computer and use it in GitHub Desktop.
Save vijaycs85/0a51bd0920b641aba819 to your computer and use it in GitHub Desktop.
<?php
$data = array(
'row1' => array(
'col1' => 'value1',
'col2' => 'value2',
'col3' => 'value3',
'col4' => 'value4',
),
'row2' => array(
'col1' => 'value1',
'col2' => 'value2',
'col3' => 'value3',
'col4' => 'value4',
),
);
$prefix = 'foo';
array_walk_recursive($data, function(&$value) use ($prefix) {
$value = $prefix . '-' . rand() . '-' . $value;
});
print_r($data);
// Result will be
Array
(
[row1] => Array
(
[col1] => foo-808219862-value1
[col2] => foo-1123986045-value2
[col3] => foo-779885783-value3
[col4] => foo-139808836-value4
)
[row2] => Array
(
[col1] => foo-864851992-value1
[col2] => foo-1640224340-value2
[col3] => foo-2018795883-value3
[col4] => foo-422754453-value4
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment