String Length ??
| From: | gordon stewart | Date: | Mon, 22 Mar 2004 12:46:02 +0000 |
| Subject: | String Length ?? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-181131@lists.php.net to get a copy of this message | ||
Hi there
I'm new to PHP (as some may know)...
ive spotted / Found the answers to 2-3 problems
tonight - By looking through the PHP documentation..
but this problem is perplexing..
Ok - Ive got a FORM - Which basically, I put lots of
text into it (For testing purposes, I go to news
websites & copy entire articles).
The PHP script chops up the paragraphs - into one long
line of text (one line per paragraph..), & its in an
array $text.
Ok - I loop through the array, & all the text is how
it should be - displaying properly..
PROBLEM :-
Now - All I want to know - Is how long each line is -
(eg number of characters - Ive already removed
double-spaces & its now single-spacing (if any)..)
EG - Is a line 34 characters long, 127, 945 ?
Ive looked through the PHP 'Functions' & the PHP
'documentation' for "length" (couldnt find anything..
??)
Ive found this command :-
http://nz2.php.net/strlen
Which seems perfectly fine...
Ive got this code (without the === signs)
=======
foreach ($text as $color) {
echo "SAF '$color' - ";
echo "<B>".strlen($color)."</B><BR>\n";
}
=======
the SAF is only for my reference - See it on the
screen..
QUESTION :-
Is this the right code to use ? to find the length of
each line ? ($color) - No worries - Ive just copied
code from the web..)
PROBLEM :-
It looks fine - EXCEPT when I see a 3-line paragraph -
& the PHP code is telling me its over 1,200 characters
long..
(assuming 80 characters per line, 100 AT MAXIMUM) -
thats only 240 -300 characters...
If the paragraph were 1200 characters - That would
need 8-10 lines of text...
So - Im asking here (see above)... - If Ive got the
correct code / Command...
Thanks for the help...
G
__________________________________
Do you Yahoo!?
Yahoo! Finance Tax Center - File online. File on time.
http://taxes.yahoo.com/filing.html