fork download
  1. <?php
  2.  
  3. $x = '-23.5209 -46.46466 -23.52008 -46.465952 -23.519253 -46.467239 -23.518808 -46.466901 -23.518738 -46.466848 -23.518411 -46.466597 -23.518349 -46.46658 -23.51834 -46.46657 -23.517974 -46.466157 -23.517879 -46.466052 -23.517859 -46.466074 -23.51733 -46.466632 -23.516765 -46.467217 -23.516693 -46.467292 -23.516206 -46.467802 -23.516169 -46.467841 -23.516179 -46.467859 -23.516229 -46.467909 -23.516329 -46.467981 -23.518096 -46.469056';
  4.  
  5. $x = preg_replace('#(-[\d.]+)\s(-[\d.]+)(\s|$)#', '$1,$2|', $x);
  6. $x = rtrim($x, '|'); //Remove o pipe extra no final
  7.  
  8. echo $x;
Success #stdin #stdout 0.01s 82944KB
stdin
Standard input is empty
stdout
-23.5209,-46.46466|-23.52008,-46.465952|-23.519253,-46.467239|-23.518808,-46.466901|-23.518738,-46.466848|-23.518411,-46.466597|-23.518349,-46.46658|-23.51834,-46.46657|-23.517974,-46.466157|-23.517879,-46.466052|-23.517859,-46.466074|-23.51733,-46.466632|-23.516765,-46.467217|-23.516693,-46.467292|-23.516206,-46.467802|-23.516169,-46.467841|-23.516179,-46.467859|-23.516229,-46.467909|-23.516329,-46.467981|-23.518096,-46.469056