Embed an array without the first element

I have an array like this:

[0]=>array( [cname] => ABC [12] => 60.7500 [13] => 33.7500 [14] => 47.7500 [15] => 86.0000 [16] => 62.2500 [17] => 59.5000 [18] => 78.0000 [19] => 42.7500 [20] => 36.0000 [21] => 40.0000 [22] => 40.0000 [23] => 24.0000 ) ) 

Now I need to print cname in one field, and in the next field I need to print my data using the implode function. It is working fine. But when I blow it up, it also gives the name of the company, which I don’t want.

Desired Result:

 Name: ABC Data: 60.7500, 33.7500, 47.7500 .... 

How to skip the first element using implode?

+6
source share
3 answers

Just copy the array and then remove the cname property before calling implode .

 $copy = $arr; unset($copy['cname']); implode($copy); 

This works because in PHP, copies of the destination array . (Bizarre, but it works.)

+9
source

Use array_shift and then implode .

 $array = YOUR_ORIGINAL_ARRAY; $cname = array_shift($array); $string = implode(',', $array); 
+5
source

Try the following:

 $newArray = array_shift($yourArray); $implodedArray = implode(",", $newArray); 
+2
source

Source: https://habr.com/ru/post/981592/


All Articles