pca6
New Member
Posts: 6
|
Post by pca6 on Sept 11, 2012 11:51:18 GMT -5
made html form with <textarea> box and trying to use strlen() function to count characters (or bytes) entered in this textarea. i use a $_get to fetch the string and the strlen() function to count, but my count is often coming out higher than it should be, like it's counting characters (or bytes) i don't know about. any clues?
|
|
|
Post by Bob P on Sept 11, 2012 14:06:57 GMT -5
A good debugging technique with strings:
On server side capture your string via $_GET['strName'] and assign to a var and then immediately echo out the string
OR
On the server side immediately print out the $_GET array using print_r or var_dump which actually tells you the number of chars being stored
Bob
|
|
|
Post by corbinp on Sept 11, 2012 14:35:17 GMT -5
i was able to do this creating a form that uses the post method instead of get. then i retrieved the string by using $_POST['textAreaName']
|
|
pca6
New Member
Posts: 6
|
Post by pca6 on Sept 11, 2012 14:43:27 GMT -5
thank you for your efforts.
only in discovering the answer was i able to think of the right question. when constructing my html <textarea> i used a "hard" wrap rather than "soft" so it was counting the white spaces to the end of the line of each row of text.
i originally wrote <textarea rows=10 cols=180 name="counttext" wrap="hard">.
changing the wrap to "soft" gave me the correct count.
|
|