urban Posted April 4, 2009 Share Posted April 4, 2009 i have this 52.88239122226187, -0.3515625 how do i split this from the "," into an array xcords[ycords] Link to comment https://forums.phpfreaks.com/topic/152538-split-a-var-on-echo/ Share on other sites More sharing options...
taquitosensei Posted April 4, 2009 Share Posted April 4, 2009 explode it on the , $string="52.88239122226187, -0.3515625"; $string_exp=explode(",", $string); $coord=array( 'xcoord'=>$string_exp[0], 'ycoord'=>$string_exp[1] ); Link to comment https://forums.phpfreaks.com/topic/152538-split-a-var-on-echo/#findComment-801179 Share on other sites More sharing options...
kenrbnsn Posted April 4, 2009 Share Posted April 4, 2009 Do it this way: <?php $xy=array(); $string="52.88239122226187, -0.3515625"; list($xy['xcoord'],$xy['ycoord']) = explode(',',$string); echo '<pre>' . print_r($xy,true) . '</pre>'; ?> Ken Link to comment https://forums.phpfreaks.com/topic/152538-split-a-var-on-echo/#findComment-801203 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.