0

I execute a postgresql query to a database using PDO and I get back as repsonse strings in the form of:

POINT(23.7336253085595 38.0002872112492)

How can I get the numbers of these strings and store them into to different variables?

That's my code in order to send the query question:

include 'postgreConnect.php';



$maxGid = 1084;
for ($rowPostGis=1; $rowPostGis<=$maxGid;$rowPostGis++){

$stmt = $dbconn->prepare("SELECT ST_AsText(ST_Transform(geom, 4326)) AS geom FROM part_athens_centroids WHERE gid = :rowPostGis;");
$stmt->execute(array('rowPostGis' => $rowPostGis));

while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
    $geom = $row['geom'];
    echo($geom);
    //echo($geom);
}   
}
1

1 Answer 1

1

I would look into http://php.net/manual/en/function.explode.php this will convert your string into an array of strings that you can use http://php.net/manual/en/function.intval.php to convert each string to an int. You may need to crop the query result down to just the numbers for that use http://php.net/manual/en/function.substr.php.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.