i'm trying to create array with php, it looks works, but i want to make the data inside array does not have specified number.
php code :
<?php
$list = array("de73e0d5e8a567bb82f158c88a549b14", "94ce4f4928738ef54af52acd716704ee", "8628401848468301a6b0b19001cb08df");
$list2 = array(2, 1, 3);
$new = array();
for ($i=0; $i < count($list); $i++) {
$new[$list2[$i] - 1] = $list[$i];
}
$encode = json_encode($new);
print_r($encode);
?>
the result :
{
"0": "94ce4f4928738ef54af52acd716704ee",
"1": "de73e0d5e8a567bb82f158c88a549b14",
"2": "8628401848468301a6b0b19001cb08df"
}
the result that i want :
[
"94ce4f4928738ef54af52acd716704ee",
"de73e0d5e8a567bb82f158c88a549b14",
"8628401848468301a6b0b19001cb08df"
]
is it possible to make it the array into square bracket and not become braces, i success make the braces into square bracket by changing list2 variable into $list2 = array(1, 2, 3) but i need the code still into $list2 = array(2, 1, 3)