Reputation: 89
I'm using PHP to call a Js function with values generated by PHP.
$fp = fopen($_FILES['file']['tmp_name'], 'rb');
while(($line = fgets($fp)) !== false)
{
$split = explode(":", $line);
echo '
<script type="text/javascript">
var a = updateHashes("' . $split[0] . '", "' . $split[1] . '");
console.log(a);
</script>';
}
But my code adds some line breaks to the code, which cause errors as you can see in the following screenshot:
What could I do to fix this?
Upvotes: 0
Views: 44
Reputation: 9161
You can try to use the php trim() function on each line, that should solve.
$split = explode(":", trim($line));
Upvotes: 1