Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Change the format returned by the array

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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

[560,515,620,544,674,602,745,755,522,545,555,562,563,573,584,643,696,698,699,700,709,730,735,590]

>Solution :

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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading