bobbinsbro Posted October 29, 2008 Share Posted October 29, 2008 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> Quote Link to comment https://forums.phpfreaks.com/topic/130610-unexpected-t_variable-error/page/2/#findComment-677738 Share on other sites More sharing options...
discussnow Posted October 29, 2008 Author Share Posted October 29, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/130610-unexpected-t_variable-error/page/2/#findComment-677742 Share on other sites More sharing options...
discussnow Posted October 29, 2008 Author Share Posted October 29, 2008 Is there away to trigger the explode function with more than one variable, such as a question mark and a period? Quote Link to comment https://forums.phpfreaks.com/topic/130610-unexpected-t_variable-error/page/2/#findComment-677745 Share on other sites More sharing options...
bobbinsbro Posted October 29, 2008 Share Posted October 29, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/130610-unexpected-t_variable-error/page/2/#findComment-677749 Share on other sites More sharing options...
sasa Posted October 29, 2008 Share Posted October 29, 2008 $result = split(',|\.|\?',$para); Quote Link to comment https://forums.phpfreaks.com/topic/130610-unexpected-t_variable-error/page/2/#findComment-677762 Share on other sites More sharing options...
bobbinsbro Posted October 29, 2008 Share Posted October 29, 2008 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() Quote Link to comment https://forums.phpfreaks.com/topic/130610-unexpected-t_variable-error/page/2/#findComment-677769 Share on other sites More sharing options...
sasa Posted October 29, 2008 Share Posted October 29, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/130610-unexpected-t_variable-error/page/2/#findComment-677791 Share on other sites More sharing options...
bobbinsbro Posted October 29, 2008 Share Posted October 29, 2008 awesome. thanx sasa. Quote Link to comment https://forums.phpfreaks.com/topic/130610-unexpected-t_variable-error/page/2/#findComment-677805 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.