WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-11-2004, 04:50 PM
WebProWorld Member
 

Join Date: Nov 2003
Location: Bedford, Va.
Posts: 72
wmabear54 RepRank 0
Default count lines within a div

Hi All
I have a question about php, is there a function that would count the lines of output within a div so that I can calculate the height in px of the div so when it is printed to the browser that I can recalulate the height of the two columns on the right and left like so height:<?php echo (0 + $v1 + $v2); ?>px; and then the same variable would be assigned inside the additions for the top:<?php echo (150 $v1+ $v2); ?>px;. The $v1 is the one I am working on now, $v2 will be used for another additions. I could use mb_strlen() but this may not be as accurate as the number of lines.

Thanks in advance
Mike
Reply With Quote
  #2 (permalink)  
Old 11-17-2004, 10:06 AM
Deep13's Avatar
WebProWorld Veteran
 

Join Date: Dec 2003
Location: India
Posts: 306
Deep13 RepRank 0
Default

echo substr_count ($string,"
");

each line will have
in order to print the text in new line...

so you will get No. of
and then you can do whatever you want with it...

I hope this is what you wanted...

Deep
Reply With Quote
  #3 (permalink)  
Old 11-19-2004, 01:13 AM
WebProWorld Member
 

Join Date: Nov 2003
Location: Bedford, Va.
Posts: 72
wmabear54 RepRank 0
Default

Hi Deep13

Thanks that is exactly what I was looking for.

Thank again
Mike
Reply With Quote
  #4 (permalink)  
Old 11-20-2004, 05:53 PM
WebProWorld New Member
 

Join Date: Jul 2003
Posts: 1
brucepainter RepRank 0
Default

This solution looks like it would work in some situations, but what the line of text being written to the browser wraps? There won't be a
tag to count?

For your purposes that may not matter I don't know, but I wanted to bring that up in case someone else had a solution that took that into account as well.
Reply With Quote
  #5 (permalink)  
Old 11-21-2004, 12:23 AM
Deep13's Avatar
WebProWorld Veteran
 

Join Date: Dec 2003
Location: India
Posts: 306
Deep13 RepRank 0
Default

Quote:
Originally Posted by brucepainter
This solution looks like it would work in some situations, but what the line of text being written to the browser wraps? There won't be a
tag to count?

For your purposes that may not matter I don't know, but I wanted to bring that up in case someone else had a solution that took that into account as well.
Oh yes, there might be other options too coz php has lot of functions...

2nd thing...
you need to specifly atleast one identifier which says this is new line...

it can be
or any other character (.) which is not used for any other purpose in the text.

otherwise i don't know whether it will be possible for php to identify or not..

Deep
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Tags: , , ,



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Search Engine Optimization by vBSEO 3.2.0