-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample_multi.php
More file actions
70 lines (59 loc) · 1.67 KB
/
example_multi.php
File metadata and controls
70 lines (59 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
/**
* File: example_single.php
* Created by Joao Rito on 27/02/18.
* Last modified by Joao Rito on 27/02/18 14:06
* https://github.com/joaorito/php_RenameKeys
*/
include_once ('function.php');
/** Original array */
$original = array(
'DataHora' => date('YmdHis'),
'Produto' => array(
array('Nome' => 'Produto 1', 'Value' => 10.00, 'Estoque' => true),
array('Nome' => 'Produto 2', 'Value' => 15.00, 'Estoque' => true),
array('Nome' => 'Produto 3', 'Value' => 20.00, 'Estoque' => false)
),
'Entrega' => array(
'Logradouro' => 'Rua Joao, 123',
'Cidade' => 'Sao Paulo',
'Estado' => 'SP',
'Telefone' => array(
array('DDD' => '11', 'Telefone' => '928374762'),
array('DDD' => '11', 'Telefone' => '675675676'),
array('DDD' => '11', 'Telefone' => '9278784762'),
)
)
);
/** Map of keys to replace */
$map = array(
'DataHora' => 'Date',
'Produto' => 'Product',
'Nome' => 'Name',
'Preco' => 'Price',
'Estoque' => 'Avaiable',
'Entrega' => 'Delivery',
'Logradouro' => 'Address',
'Cidade' => 'City',
'Estado' => 'State',
'DDD' => 'Area Code',
'Telefone' => 'Phone'
);
$new = replaceKey($original,$map);
?>
<div style="width: 40%; display: inline-block">
<div>Original Array</div>
<pre style="border: 1px; padding: 5px; ">
<?php
print_r($original);
?>
</pre>
</div>
<div style="width: 40%; display: inline-block">
<div>New Array</div>
<pre style="border: 1px; padding: 5px; ">
<?php
print_r($new);
?>
</pre>
</div>