Forum


Replies: 3   Views: 3205
How do i deal with html in a word fragment please
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by maxelcat  · 16-10-2017 - 10:47

Hi

I am trying to produce a report which is based on three pieces of data, 1 of which has html in it. Altogether the same 3 pieces of data crop up about 20 times and so i am creating an array of arrays like this:

Array ( [SUBJECT] => Relationships and Living in the Wider World [DESCRIPTION] =>

<p>Pupils respond.....
[GRADE] => P6c ) 
Array ( [SUBJECT] => Independence and Personal Wellbeing [DESCRIPTION] =>

<p>Pupils carry ....
[GRADE] => P6b ) 
Array ( [SUBJECT] => Attention Motivation and Self Reflection [DESCRIPTION] => <p>Pupils...

etc

I then create on big wordfragment like this:

foreach ($tabledata as $value){
                                
                        
                                $titlewf->addtext($value['SUBJECT'].' '.$value['GRADE'],
                                                                 
                                                                 array('bold'=>'true',
                                                                          'color'=>'2e74b5',
                                                                           'font'=>'Arial',
                                                                           'fontSize'=>'12'
                                                                          )
                                                                 
                                                                 );
                                
                                
                                $titlewf->addtext($value['DESCRIPTION'],
                                                                          array('bold'=>0,
                                                                                   'color'=>'0ff000',
                                                                                   'font'=>'Arial',
                                                                                   'fontSize'=>'10'
                                                                                   )
                                                                          );
                                
                        
                        } //foreach

this all works fine - the data is printed out to the worddoc. The trouble is that the html code prints out rather than adds the styles. It is only very simple html like <p>, <strong> and <ul>

I don't really know how to handle the fact that $value['DESCRITPION'] was created via an editor and therefore contains HTML.

I am sure this is easy - but I can't see how to do it

This is a link to a sample of the worddoc produced so you can see the issue.

Many thanks in advance - though this is a 'demo' version, I have bought a licence.