Sorry for posting like this but I am learning I want all the results to have a hr or any html based line except the last one I put a line break but it won't look  good help me foreach ($newsqry-&gt;result() as $n) {     $nr=$n-&gt;numrows();     $nlink = array_keys($routesAll, &quot;news/index/&quot; . $n-&gt;n_id);     ?&gt;             &lt;div class=&quot;row&quot;&gt;             &lt;div class=&quot;col-md-6 imgpost&quot;&gt;                             &lt;a class=&quot;post-imgn&quot; href=&quot;&lt;?=site_url($nlink)?&gt;&quot;&gt;                                 &lt;img  class=&quot;&quot;src=&quot;&lt;?=base_url(&quot;assets/uploads/news/thmb/$n-&gt;img&quot;)?&gt;&quot;alt=&quot;&lt;?=character_limiter($n-&gt;title,'50')?&gt;&quot;&gt;                             &lt;/a&gt;                         &lt;/div&gt;                             &lt;div class=&quot;col-md-6 descpost&quot;&gt;                                 &lt;div class=&quot;post-category com&quot; &gt;              &lt;?php     $t = $n-&gt;tags;     $s = explode(',', $t);     foreach ($s as $a) {         ?&gt;                             &lt;a class=&quot;tags&quot; href=&quot;&lt;?=site_url(&quot;news/view?tag=&quot;.strtolower(str_replace(' ','-',$a)))?&gt;&quot;&gt;&lt;?=ucwords($a)?&gt;&lt;/a&gt;                         &lt;?php } ?&gt;             &lt;/div&gt;                                 &lt;h3 class=&quot;post-title news&quot;&gt;                                     &lt;a href=&quot;&lt;?=site_url($nlink)?&gt;&quot;&gt;&lt;?=character_limiter($n-&gt;title,'100')?&gt;&quot;&lt;/a&gt;                                 &lt;/h3&gt;                                 &lt;ul class=&quot;post-meta&quot;&gt;                                     &lt;li&gt;&lt;a href=&quot;&lt;?=site_url(&quot;news/view?author=&quot;.strtolower(str_replace(' ','-',$n-&gt;author)))?&gt;&quot;&gt;&lt;?=$n-&gt;author?&gt;&lt;/a&gt;&lt;/li&gt;                                     &lt;li&gt;&lt;i class=&quot;fa fa-clock-o&quot; aria-hidden=&quot;true&quot;&gt;&lt;/i&gt; &lt;?=date(&quot;h:i A&quot;,strtotime($n-&gt;time))?&gt; &lt;?=date(&quot;F-d-y&quot;,strtotime($n-&gt;date))?&gt;&lt;/li&gt;                                 &lt;/ul&gt;                                 &lt;p class=&quot;descfornews&quot;&gt;&lt;?=character_limiter(strip_tags($n-&gt;desc),'190')?&gt;&lt;/p&gt;                             &lt;/div&gt;                         &lt;/div&gt;                         &lt;?php if($nr&lt;1){echo &quot;&lt;hr&gt;&quot;;}else{ echo &quot;&lt;h3&gt;End of Page&lt;/h3&gt;&quot;;}?&gt;                 &lt;?php } ?&gt;
123088
I am writing a SQL query creator using some parameters. In Java, it's very easy to detect the last element of an array from inside the for loop by just checking the current array position with the array length.  for(int i=0; i&lt; arr.length;i++){      boolean isLastElem = i== (arr.length -1) ? true : false;         }   In PHP they have non-integer indexes to access arrays. So you must iterate over an array using a foreach loop. This becomes problematic when you need to take some decision (in my case to append or/and parameter while building query).   I am sure there must be some standard way of doing this.   How do you solve this in PHP?
9353
I have a loop that is doing some error checking in my PHP code. Originally it looked something like this...  foreach($results as $result) {     if (!$condition) {         $halt = true;         ErrorHandler::addErrorToStack('Unexpected result.');     }      doSomething();  }  if (!$halt) {     // do what I want cos I know there was no error }   This works all well and good, but it is still looping through despite after one error it needn't. Is there a way to escape the loop?
27970
Let's say I write up a bunch of rows and decide I want to make it a list:  Item 1 Another Item Something Else   When I mark each line and click the "List" button (doesn't matter which one), the Editor takes all three rows and makes one list item out of them, ignoring the line-breaks.  The output will simply be:  - Item 1 Another Item Something Else   It would be far more useful and less buggy if it would instead create one list item for each line:  - Item 1 - Another Item - Something Else
21321
pre tags are super-useful for code blocks in HTML and for debugging output while writing scripts, but how do I make the text word-wrap instead of printing out one long line?
67152
I would like to create a page where all images which reside on my website are listed with title and alternative representation.  I already wrote me a little program to find and load all HTML files, but now I am stuck at how to extract src, title and alt from this HTML:  &lt;img src="/image/fluffybunny.jpg" title="Harvey the bunny" alt="a cute little fluffy bunny" />  I guess this should be done with some regex, but since the order of the tags may vary, and I need all of them, I don't really know how to parse this in an elegant way (I could do it the hard char by char way, but that's painful).
87044
I need to add line breaks in the positions that the browser naturally adds a newline in a paragraph of text.  For example:  &lt;p&gt;This is some very long text \n that spans a number of lines in the paragraph.&lt;/p&gt;  This is a paragraph that the browser chose to break at the position of the \n  I need to find this position and insert a &lt;br /&gt;  Does anyone know of any JS libraries or functions that are able to do this?  The only solutuion that I have found so far is to remove tokens from the paragraph and observe the clientHeight property to detect a change in element height. I don't have time to finish this and would like to find something that's already tested.  Edit: The reason I need to do this is that I need to accurately convert HTML to PDF. Acrobat renders text narrower than the browser does. This results in text that breaks in different positions. I need an identical ragged edge and the same number of lines in the converted PDF.  Edit:  @dtsazza: Thanks for your considered answer. It's not impossible to produce a layout editor that almost exactly replciates HTML I've written 99% of one ;)  The app I'm working on allows a user to create a product catalogue by dragging on 'tiles' The tiles are fixed width, absolutely positioned divs that contain images and text. All elemets are styled so font size is fixed. My solution for finding \n in paragraph is ok 80% of the time and when it works with a given paragrah the resulting PDF is so close to the on-screen version that the differences do not matter. Paragraphs are the same height (to the pixel), images are replaced with high res versions and all bitmap artwork is replaced with SVGs generated server side.  The only slight difference between my HTML and PDF is that Acrobat renderes text slightly more narrowly which results in line slightly shorter line length.  Diodeus's solution of adding span's and finding their coords is a very good one and should give me the location of the BRs. Please remember that the user will never see the HTML with the inserted BRs - these are added so that the PDF conversion produces a paragraph that is exactly the same size.  There are lots of people that seem to think this is impossible. I already have a working app that created extremely accurate HTML->PDF conversion of our docs - I just need a better solution of adding BRs because my solution sometimes misses a BR. BTW when it does work my paragraphs are the same height as the HTML equivalents which is the result we are after.  If anyone is interested in the type of doc i'm converting then you can check ou this screen cast:    Edit: Many thanks to Diodeus - your suggestion was spot on.   Solution: for my situation it made more sense to wrap the words in spans instead of the spaces.  var text = paragraphElement.innerHTML.replace(/ /g, '&lt;/span&gt; &lt;span&gt;');  text = "&lt;span&gt;"+text+"&lt;/span&gt;"; //wrap first and last words.  This wraps each word in a span. I can now query the document to get all the words, iterate and compare y position. When y pos changes add a br.  This works flawlessly and gives me the results I need - Thank you!
29281
In my page.tpl.php I'm doing this to display one of my view:  print views_embed_view('teaserview', 'default');   That gives me the following html output:  &lt;span thmr="thmr_10"&gt; &lt;div class="view view-teaserview view-id-teaserview view-display-id-default view-dom-id-e051ba535ce9aac6cd9a0d564b3dbb29 contextual-links-region"&gt;     &lt;div class="contextual-links-wrapper"&gt;         &lt;span thmr="thmr_16"&gt;         &lt;ul class="contextual-links"&gt;             &lt;li class="views-ui-edit first last"&gt;&lt;span thmr="thmr_17"&gt;&lt;a href="/kbi/admin/structure/views/view/teaserview/edit/default?destination=node/3"&gt;Edit view&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;         &lt;/ul&gt;         &lt;/span&gt;     &lt;/div&gt;     &lt;div class="view-content"&gt;         &lt;span thmr="thmr_15"&gt;         &lt;div class="views-row views-row-1 views-row-odd views-row-first views-row-last"&gt;             &lt;span thmr="thmr_14"&gt;             &lt;span thmr="thmr_11"&gt;&lt;span thmr="thmr_12"&gt;&lt;span thmr="thmr_13"&gt;&lt;img src="http://127.0.0.1/kbi/sites/default/files/teaser_2.jpg" width="1029" height="308" alt="" /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;         &lt;/div&gt;         &lt;/span&gt;     &lt;/div&gt; &lt;/div&gt; &lt;/span&gt;   But the only thing that I really need is  &lt;img src="http://127.0.0.1/kbi/sites/default/files/teaser_2.jpg" width="1029" height="308" alt="" /&gt;   Is there a possibility to modify the views_embed_view call so that I get only the needed data?   There would be the possibility to modify all the views .tpl.php files but I hope there's an easier way to do this.   I also read about the semantic views module but I didn't understand how to configure my view with it so that i get only the needed markup as output. it didn't seem to have any effect.
86659
With this URL:  .  It is broken unless I add a \ to the end in front of a period:   And it works. However in the comments, I can't get this to work: (See the comments)
22401
This is similar to:  and , but is slightly different. The other questions are asking more of a why question, not a please do this question. I am asking for a specific implementation of Markdown tables. I found  on making tables in Markdown using  or . The code to make a table looks like this:  | Left align | Right align | Center align | |:-----------|------------:|:------------:| | This       |        This |     This     | | column     |      column |    column    | | will       |        will |     will     | | be         |          be |      be      | | left       |       right |    center    | | aligned    |     aligned |   aligned    |   And the result is:   This is much different than , which says that Jeff doesn't want the &lt;tr&gt;&lt;td&gt; tags allowed on the SE sites. This request has a specific feature request, as opposed to the other questions which don't really have a decisive yes/no answer.  Here are some specific posts that need this type of support:
82526
Some compilers (especially C or C++ ones) give you warnings about:  No new line at end of file   I thought this would be a C-programmers-only problem, but github displays a message in the commit view:  \ No newline at end of file   for a PHP file.  I understand the preprocessor thing explained in , but what has this to do with PHP? Is it the same include() thing or is it related to the \r\n vs \n topic?   What is the point in having a new line at the end of a file?
87922
I used the Bing webmaster tool's SEO analyzer on my website, and it reported:     There are multiple  tags on the page.   It recommends that there should only be one &lt;h1&gt; tag on the page.  The page is a listing of blog posts for a category. So each blog entry is structured like this.  &lt;article&gt;     &lt;header&gt;&lt;h1&gt;&lt;a&gt;...&lt;/a&gt;&lt;/h1&gt;&lt;/header&gt;     &lt;p&gt;summary...&lt;/p&gt; &lt;/article&gt; &lt;article&gt;     &lt;header&gt;&lt;h1&gt;&lt;a&gt;...&lt;/a&gt;&lt;/h1&gt;&lt;/header&gt;     &lt;p&gt;summary...&lt;/p&gt; &lt;/article&gt; &lt;article&gt;     &lt;header&gt;&lt;h1&gt;&lt;a&gt;...&lt;/a&gt;&lt;/h1&gt;&lt;/header&gt;     &lt;p&gt;summary...&lt;/p&gt; &lt;/article&gt; &lt;article&gt;     &lt;header&gt;&lt;h1&gt;&lt;a&gt;...&lt;/a&gt;&lt;/h1&gt;&lt;/header&gt;     &lt;p&gt;summary...&lt;/p&gt; &lt;/article&gt;   How is this invalid? I thought this was the correct way to describe a post in HTML5.
20608
I'm currently adding verbose tooltips to our site, and I'd like (without having to resort to a whizz-bang jQuery plugin, I know there are many!) to use carriage returns to format the tooltip.  To add the tip I'm using the title attribute. I've looked around the usual sites and using the basic template of:  &lt;a title='Tool?Tip?On?New?Line'&gt;link with tip&lt;/a&gt;   I've tried replacing the ? with:   &lt;br /&gt; &amp;013; / &amp;#13; \r\n Environment.NewLine (I'm using C#)   None of the above works. Is it possible?
35335
I'm making a tabular and I'd like to automatically do a like break rather than going beyond the page.   This is my tabular code:  \begin{table}[h] \begin{tabular}{|l|l|l|} Use Case Navn:          &amp; \multicolumn{2}{l}{Opret Server} \\ Scenarie:               &amp; \multicolumn{2}{l}{At oprette en server med bestemte regler som tillader folk at spille sammen. More Text more text More Text} \\ \end{tabular} \end{table}   This is my preamble:  \documentclass[danish,a4paper,twoside,11pt]{report} \usepackage{babel} \usepackage[utf8x]{inputenc} \usepackage{natbib} \usepackage{graphicx} \usepackage{epstopdf} \usepackage{titling} \usepackage{color} \usepackage{xcolor} \usepackage{nag} \usepackage{tabularx}  \newcommand{\myparagraph}[1]{\paragraph{#1}\mbox{}\\}   This is how it looks right now:
23120
How can i add a line break to the text area in a html page? i use VB.net for server side coding.
117043
Does anyone know how I can prevent the text in a table cell from wrapping?  This is for the header of a table, and the heading is a lot longer than the data under it, but I need it to display on only one line.  It is okay if the column is very wide.  The HTML of my (simplified) table looks like this:  &lt;table&gt;   &lt;thead&gt;     &lt;tr&gt;       &lt;th&gt;         &lt;div&gt;Really long column heading&lt;/div&gt;       &lt;/th&gt;       &lt;th&gt;         &lt;div&gt;Really long column heading&lt;/div&gt;       &lt;/th&gt;       &lt;th&gt;         &lt;div&gt;Really long column heading&lt;/div&gt;       &lt;/th&gt;       &lt;th&gt;         &lt;div&gt;Really long column heading&lt;/div&gt;       &lt;/th&gt;       &lt;th&gt;         &lt;div&gt;Really long column heading&lt;/div&gt;       &lt;/th&gt;       &lt;th&gt;         &lt;div&gt;Really long column heading&lt;/div&gt;       &lt;/th&gt;       &lt;th&gt;         &lt;div&gt;Really long column heading&lt;/div&gt;       &lt;/th&gt;     &lt;/tr&gt;   &lt;/thead&gt;   &lt;tbody&gt;     &lt;tr&gt;       &lt;td&gt;         &lt;div&gt;data&lt;/div&gt;       &lt;/td&gt;       &lt;td&gt;         &lt;div&gt;data&lt;/div&gt;       &lt;/td&gt;       &lt;td&gt;         &lt;div&gt;data&lt;/div&gt;       &lt;/td&gt;       &lt;td&gt;         &lt;div&gt;data&lt;/div&gt;       &lt;/td&gt;       &lt;td&gt;         &lt;div&gt;data&lt;/div&gt;       &lt;/td&gt;       &lt;td&gt;         &lt;div&gt;data&lt;/div&gt;       &lt;/td&gt;       &lt;td&gt;         &lt;div&gt;data&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt; &lt;/table&gt;   The heading itself is wrapped in a div inside the th tag for reasons pertaining to the javascript on the page.    The table is coming out with the headings wrapping onto multiple lines.  This seems to only happen when the table is sufficiently wide, as the browser is trying to avoid horizontal scrolling.  In my case, though, I want horizontal scrolling.  Any ideas?
108151
I ran into a regression change in the post formatting engine . If you try to embed an image using the exclamation sign syntax ![foo][bar] and the paragraph starts with a &lt;p&gt; or &lt;hr&gt; tag, the image formatting code is shown as literal text, not as an image. Example: This image is in a bare paragraph and shows up:  This image is after a &lt;p&gt; tag and doesn't show up: ![(a hand-drawn red circle as a test image)][1] As a possible workaround, you can use an &lt;img&gt; tag:  I found this when I was writing .  The image embedded in the post , but .  This confused me thoroughly, because I was trying to edit a part of the post other than the image. Apparently , but it doesn't seem to be mentioned on Meta SE yet.
50375
I'm trying to convert some LaTeX into HTML but my code listings don't preserve their code coloring. Why is that and how do I fix it?  This is what it looks like:    Side note: I'm also wondering why the caption on the table was removed.  Edit  Here is an example listing with colors:  \documentclass{article} \usepackage{color} \usepackage{listings} \lstset{     basicstyle=\footnotesize\ttfamily,     language=[Sharp]C,      keywordstyle=\color[rgb]{0,0,1.0}\bfseries,       commentstyle=\color[rgb]{0.133,0.545,0.133}\bfseries, }  \begin{document} \begin{lstlisting} int x = 10;  // This is a comment string str = "hello"; \end{lstlisting} \end{document}   This produces the following HTML when doing: htlatex myfile.tex:  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"     "http://www.w3.org/TR/html4/loose.dtd"&gt;   &lt;html &gt;  &lt;head&gt;&lt;title&gt;&lt;/title&gt;  &lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"&gt;  &lt;meta name="generator" content="TeX4ht (http://www.cse.ohio-state.edu/~gurari/TeX4ht/)"&gt;  &lt;meta name="originator" content="TeX4ht (http://www.cse.ohio-state.edu/~gurari/TeX4ht/)"&gt;  &lt;!-- html --&gt;  &lt;meta name="src" content="LaTeX4.tex"&gt;  &lt;meta name="date" content="2012-07-20 12:30:00"&gt;  &lt;link rel="stylesheet" type="text/css" href="LaTeX4.css"&gt;  &lt;/head&gt;&lt;body  &gt;    &lt;!--l. 12--&gt;    &lt;div class="lstlisting" id="listing-1"&gt;&lt;span class="label"&gt;&lt;a   id="x1-2r1"&gt;&lt;/a&gt;&lt;/span&gt;&lt;span  class="cmtt-8"&gt;int&lt;/span&gt;&lt;span  class="cmtt-8"&gt;&amp;#x00A0;&lt;/span&gt;&lt;span  class="cmtt-8"&gt;x&lt;/span&gt;&lt;span  class="cmtt-8"&gt;&amp;#x00A0;&lt;/span&gt;&lt;span  class="cmtt-8"&gt;=&lt;/span&gt;&lt;span  class="cmtt-8"&gt;&amp;#x00A0;&lt;/span&gt;&lt;span  class="cmtt-8"&gt;10;&lt;/span&gt;&lt;span  class="cmtt-8"&gt;&amp;#x00A0;&lt;/span&gt;&lt;br /&gt;&lt;span class="label"&gt;&lt;a   id="x1-3r2"&gt;&lt;/a&gt;&lt;/span&gt;&lt;span  class="cmtt-8"&gt;&amp;#x00A0;&lt;/span&gt;&lt;br /&gt;&lt;span class="label"&gt;&lt;a   id="x1-4r3"&gt;&lt;/a&gt;&lt;/span&gt;&lt;span  class="cmtt-8"&gt;//&lt;/span&gt;&lt;span  class="cmtt-8"&gt;&amp;#x00A0;&lt;/span&gt;&lt;span  class="cmtt-8"&gt;This&lt;/span&gt;&lt;span  class="cmtt-8"&gt;&amp;#x00A0;&lt;/span&gt;&lt;span  class="cmtt-8"&gt;is&lt;/span&gt;&lt;span  class="cmtt-8"&gt;&amp;#x00A0;&lt;/span&gt;&lt;span  class="cmtt-8"&gt;a&lt;/span&gt;&lt;span  class="cmtt-8"&gt;&amp;#x00A0;&lt;/span&gt;&lt;span  class="cmtt-8"&gt;comment&lt;/span&gt;&lt;span  class="cmtt-8"&gt;&amp;#x00A0;&lt;/span&gt;&lt;br /&gt;&lt;span class="label"&gt;&lt;a   id="x1-5r4"&gt;&lt;/a&gt;&lt;/span&gt;&lt;span  class="cmtt-8"&gt;string&lt;/span&gt;&lt;span  class="cmtt-8"&gt;&amp;#x00A0;&lt;/span&gt;&lt;span  class="cmtt-8"&gt;str&lt;/span&gt;&lt;span  class="cmtt-8"&gt;&amp;#x00A0;&lt;/span&gt;&lt;span  class="cmtt-8"&gt;=&lt;/span&gt;&lt;span  class="cmtt-8"&gt;&amp;#x00A0;&lt;/span&gt;&lt;span  class="cmtt-8"&gt;"&lt;/span&gt;&lt;span  class="cmtt-8"&gt;hello&lt;/span&gt;&lt;span  class="cmtt-8"&gt;"&lt;/span&gt;&lt;span  class="cmtt-8"&gt;;&lt;/span&gt;     &lt;/div&gt;  &lt;/body&gt;&lt;/html&gt;   Which looks like this:    I would want the HTML result to look like this: