Jump to content

unexpected T_Variable Error


discussnow

Recommended Posts

this code works fine for me in FF 3.0.3. this is what i think you wanted (i changed $_POST['send'] to $_POST['para']):

<html>
<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
<title> 
Paragraph Scrambler 
</title>
<body>  
Paste Paragraph <br>
<textarea name="para" type="text" row="5" col="5"></textarea><br>
<input name="send" type="submit" value="Submit!">
<input type="reset" value="Cancel">
</body>
<?php
if(isset($_POST['para'])){
$para  = $_POST['para'];
$result = explode('.',$para);
print_r($result);
}
?>

</html>

Link to comment
Share on other sites

this code works fine for me in FF 3.0.3. this is what i think you wanted (i changed $_POST['send'] to $_POST['para']):

<html>
<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
<title> 
Paragraph Scrambler 
</title>
<body>  
Paste Paragraph <br>
<textarea name="para" type="text" row="5" col="5"></textarea><br>
<input name="send" type="submit" value="Submit!">
<input type="reset" value="Cancel">
</body>
<?php
if(isset($_POST['para'])){
$para  = $_POST['para'];
$result = explode('.',$para);
print_r($result);
}
?>

</html>

 

Exactly! Thanks a lot, I am just learning so you can compare me to a kindergarten just learning to write :P

Link to comment
Share on other sites

i don't believe so. i think you would have to switch to using preg_split() : http://il2.php.net/manual/en/function.preg-split.php

one of the others will have to help you with putting together the proper regex, since i suck at that. i believe that there is a special code for preg functions for finding all punctuation marks. i'll post it if i can find it.

 

Edit: your preg_split() should looks something like this (i think...):

 

$result = preg_split("/\. \?/", $para);

 

too add more punctuation to use, just add more \whatever to the function.

Link to comment
Share on other sites

try

<?php
$test = 'aas,df?asd.,xxx';
$t = microtime(1);
for ($i=0;$i<10000;$i++){
$foo = split(',|\.|\?',$test);	
}
echo 'split: ',microtime(1)-$t,"\n";
$t = microtime(1);
for ($i=0;$i<10000;$i++){
$foo = preg_split('/,|\.|\?/',$test);	
}
echo 'preg_split: ',microtime(1)-$t,"\n";

?>

on my mychine otput is

split: 0.23552489280701
preg_split: 0.32364296913147

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.