php - Split string into custom format -


how can split string custom format?

input string:

14157.72,39140.94,36383.66,38508.00,8424.00 

expected output:

['14157.72'],['39140.94'],['36383.66'],['38508.00'],['8424.00'] 

current code:

foreach($amount[0] $aountlist){      //$aountlist.= "'".$aountlist->hpiamount.',';     print_r($aountlist->hpiamount);      $defineamount = [$aountlist->hpiamount]; }  

how can change code expected output?

try -

$string = '14157.72,39140.94,36383.66,38508.00,8424.00'; $temp = array(); $str = explode(',', $string); foreach($str $val){    $temp[] = "[".$val."]"; } echo implode(',', $temp); 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -