note 57517 added to function.substr
| From: | willa4you at inwind dot it | Date: | Thu, 06 Oct 2005 09:20:20 +0000 |
| Subject: | note 57517 added to function.substr | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-96500@lists.php.net to get a copy of this message | ||
I'm doing a little Guestbook for my site, and I want that the php code read the message text
word by word, to control their lenght. But, I have first to control that the following word is not a
piece of html code, so I write this control:
$stringa = '<a href="http://www.google.com>Ciao
dall'Italia!</a>';
$code = substr($stringa, 0, 1);
if ($code == "<"){
$a = strpos($stringa, ">");
$elab = substr($stringa, 0, $a+1);
$stringa = substr($stringa, $a+1);}
... ...
...
My problem is that when it does this control for the first time, $code takes the value of h, because
substr begin from "http://" not from "<a... ".
How can I explain this? Thank you for your attenction and sorry for my maccheroni/English...
----
Manual Page -- http://www.php.net/manual/en/function.substr.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+57517
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+57517&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+57517&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+57517&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+57517&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+57517&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+57517&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+57517&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+57517&report=yes
Search -- http://master.php.net/manage/user-notes.php