Hi everyone.
I am trying to create a short script to output a string of co-ordinates. The code is pasted below from my file, which is named blah.php:
[php]<?php
$coorda = $_POST[“coord”];
if ($coorda != null)
{
$coorda = strtr($coorda, “:”," “);
$coorda = strtr($coorda, “COORD:”,”\n");
echo $coorda;
}
else echo “Enter co-ordinates below”;
?>
Enter here: [/php]The intention of this code is to take a series out co-ordinates from a textarea, which will be in the following format:
COORD:N053.02.42.847:W003.01.51.446
COORD:N053.04.55.747:W002.48.54.757
COORD:N052.59.50.525:W002.48.30.004
COORD:N052.57.59.275:W003.13.7.085
COORD:N053.02.5.224:W003.09.45.498
COORD:N053.01.2.134:W002.59.49.327
And output them thus:
N053.02.42.847 W003.01.51.446
N053.04.55.747 W002.48.54.757
N052.59.50.525 W002.48.30.004
N052.57.59.275 W003.13.7.085
N053.02.5.224 W003.09.45.498
N053.01.2.134 W002.59.49.327
Thereby removing ‘COORD’ and the two instances of ‘:’. So instead of,
COORD:N052.57.59.275:W003.13.7.085
we need
N052.57.59.275 W003.13.7.085
{space}N052.57.59.275{space}W003.13.7.085.
However I have an issue here. The output will not put each of the two co-ordinates on their own line.
[php]$coorda = strtr($coorda, “COORD:”,"\n");[/php]
The “\n” linebreak isn’t being parsed in the script for some reason. So the output is:
N053.02.42.847 W003.01.51.446 N053.04.55.747 W002.48.54.757 N052.59.50.525 W002.48.30.004 N052.57.59.275 W003.13.7.085 N053.02.5.224 W003.09.45.498 N053.01.2.134 W002.59.49.327
Instead of:
N053.02.42.847 W003.01.51.446
N053.04.55.747 W002.48.54.757
N052.59.50.525 W002.48.30.004
N052.57.59.275 W003.13.7.085
N053.02.5.224 W003.09.45.498
N053.01.2.134 W002.59.49.327
Any ideas?
Many regards