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>

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

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.

is there any special reason you suggest split? (i'm not being sore lol, but i would like to learn). it's just that i found this in the php manual:

preg_split(), which uses a Perl-compatible regular expression syntax, is often a faster alternative to split()

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.