PDA

View Full Version : Minor PHP help



MrPinkPanther
25-04-2009, 09:45 AM
Ok, I have this code which writes to a text file. But when it does it writes it with a space infront. So "I am god" is written into the file as " I am god". I basically need the first space to be removed.

Heres the code:

<?php
$name = $_GET["name"];
$myFile = "data.txt";
$ab = fopen($myFile, 'w');
fwrite($ab, $name);
fclose($ab);
Header("Location: http://www.google.co.uk/");
?>

Agnostic Bear
25-04-2009, 09:52 AM
Ok, I have this code which writes to a text file. But when it does it writes it with a space infront. So "I am god" is written into the file as " I am god". I basically need the first space to be removed.

Heres the code:

trim( $_GET[ 'name' ] );

MrPinkPanther
25-04-2009, 10:04 AM
trim( $_GET[ 'name' ] );
Cheers mate, works well.

Want to hide these adverts? Register an account for free!