How to write a string containing semicolons (;) to a txt using php?

  • Thread starter Thread starter First N
  • Start date Start date
F

First N

Guest
I've been using the following php code:
<?php
$string = $HTTP_GET_VARS["string"];
$file = fopen('log.txt', 'a');
fwrite($file, $string . "\n\n");
?>
To write to a txt file "log.txt" where "string" is a value I have sent using javascript. However this code only writes the first part of the string and then cuts off, from some experimentation sending examples to it using javascript it seems like it is cutting out after a semicolon ';' in the string.
I have tried removing the semicolons by adding:
$trimmed = trim($string, ";");
and then writing $trimmed, but the same result is given. Help with this would be greatly appreciated.
 
rather than trimming in php can you not use javascript replace() method to replace the semicolon with another character?

<script type="text/javascript">

var str="test;test1";
document.write(str.replace(/;/,"*"));

</script>

Hope that gives you a heads up.
 
Back
Top