Split text by symbol: Difference between revisions

Jump to navigation Jump to search
Line 65: Line 65:
|border=1
|border=1
}}
}}
=== PHP Approach ===
PHP script
<pre>
$input_string = "25.040215, 121.512532";
$list1 = explode(",", $input_string);
$trimmed_list1 = array_map('trim', $list1);
$list2 = preg_split("/[\s,]+/", $input_string);
print_r($trimmed_list1);
print_r($list2);
</pre>
output
<pre>
Array (
  [0] => 25.040215
  [1] => 121.512532
)
</pre>


[[Category:Data transformation]]
[[Category:Data transformation]]

Navigation menu