Re: Help preserving sentence structure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2010-02-26 at 14:11 -0600, John Tamm-Buckle wrote:

> Hi, new to this list...
> 
> I'm adapting some code that generates text and want to keep the syntax.  In
> the original version the output was iterated from an array in <pre> tags.
>  That was fine for what it was, but it's now a word press plugin and the
> <pre> tags get in the way.  How do I keep the sentence structure without
> using <pre>s?  Also, I'm quite new to PHP in general... :)  Any help would
> be much appreciated!
> 
> Below is an extract of the code with some highlighting for emphasis:
> 
> function wpm_display_generator() {
> 
>     if (isset($_POST['submit_button'])) {
> 
>         // the form was submitted to this script - generate
>         // and display
>         require_once 'lib/generator.php';
>         require_once "lib/util.php";
>         require_once "lib/vocabulary.php";
>         require_once "lib/widgets.php";
> 
>         $vocab = Vocabulary::getInstance();
>         $cats = $vocab->getCategories();
>         $catName = '';
>         $sentence = '';
>         if (isset($_POST['category_choice'])) {
>             $catName = $cats[$_POST['category_choice']];
>             $gen = new wordGenerator($_POST['category_choice'],
> $_POST['length_choice']);
>             $lines = $gen->generate();
>             foreach ($lines as $line) {
>                 $sentence .= "<pre>" . $line . "</pre>";
>             }
>         }
> 
>         require 'sentence.php';
>     }
>     else {
>         require 'generator_form.php';
>     }
> }
> 
> 
> Many thanks,
> 
> John
> 


<pre> tags don't do anything to mark up a sentence. If you need to
convert the hard returns to a <br/> tag, then use nl2br()

Thanks,
Ash
http://www.ashleysheridan.co.uk



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux