0

I have the following array:

$id_utt1 = explode(',', $_GET['arr']);

$id_utt = array_unique($id_utt1);

var_dump($id_utt);

which returns the data as follows:

array(24) { [0]=> string(3) "560" [6]=> string(3) "515" [12]=> string(3) "620" [14]=> string(3) "544" [15]=> string(3) "674" [16]=> string(3) "602" [22]=> string(3) "745" [25]=> string(3) "755" [29]=> string(3) "522" [31]=> string(3) "545" [32]=> string(3) "555" [33]=> string(3) "562" [34]=> string(3) "563" [35]=> string(3) "573" [36]=> string(3) "584" [39]=> string(3) "643" [41]=> string(3) "696" [42]=> string(3) "698" [43]=> string(3) "699" [44]=> string(3) "700" [45]=> string(3) "709" [46]=> string(3) "730" [47]=> string(3) "735" [49]=> string(3) "590" }

But I need the array to keep the data this way:

[560,515,620,544,674,602,745,755,522,545,555,562,563,573,584,643,696,698,699,700,709,730,735,590]
1
  • var_dump prints it that way. If you want to see it that way do this: json_encode($id_utt); Commented Jan 2, 2023 at 11:24

1 Answer 1

1

Your return is an associative array, you need to keep the values only.

You can use :

$array = array_values($id_utt);

More explications here Convert an associative array to a simple array of its values in php

Sign up to request clarification or add additional context in comments.

2 Comments

So it returns the values ​​in the same way that it already returned to me
explode() return an associative array, array_values transform it into a simple array of the values, did you dump $array ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.