php array_unique method "puts key into array" -
im going parse json array unique values. here problem array_unique function. example:
$contract_types = [ "asset sale , purchase agreement", "asset sale , purchase agreement", "concession agreement" ];
and
return array_unique($contract_types);
gives me: [{ "0": "asset sale , purchase agreement", "2": "concession agreement" }]
what i'm doing wrong?
array_unique()
preserves keys. php docs:
note keys preserved.
if wish reindex array has consecutive integer indexes, use array_values()
:
return array_values(array_unique($contract_types));
Comments
Post a Comment