简体   繁体   中英

Convert Comma separated string to comma separated integer value in PHP

I have a one array like this.

Array ( [0] => 155 [1] => 156 [2] => 157 [3] => 158 [4] => 159 [5] => 160 [6] => 161 [7] => 162 [8] => 186 [9] => 163 [10] => 164 )

Now, I have to convert array to comma separated integer value.

But When, I use implode(',',$arr) then it count as a string.

But I need as an integer format value not a string format.

$arr_data=array(155,156 ,157, 158, 159,160,161,162 ,186,163, 164 );
$str_data=implode(',',$arr_data);
$int_data_rc= str_replace(',','',$str_data);

print_r($int_data_rc); exit; 

// output will show
  155156157158159160161162186163164

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM