Jump to content

[SOLVED] extract data from string


greenba

Recommended Posts

Hello,

 

I have the following string

$som_str = "(090316211923BP05000013912345678090316A4510.9511N01548.2855E000.02119239.890010000000L000000)"

 

What I need is to extract data from it so from this example I would get $data1 = "4510.9511"  $data2= "01548.2855" ($data1 is the value btwletters A and N, and $data2 is btw N and E)

 

Any ideas?

 

Regards,

Link to comment
https://forums.phpfreaks.com/topic/149816-solved-extract-data-from-string/
Share on other sites

<?php
$string = "(090316211923BP05000013912345678090316A4510.9511N01548.2855E000.02119239.890010000000L000000)";
list($first, $second) = explode("N", $string);
list(, $data1) = explode("A", $first);
list($data2) = explode("E", $second);

echo "Data1: {$data1} and Data2: {$data2}<br />";
?>

 

explode and list.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.