To export a Word document, add the text to the specified position of the document. for example, after the previous paragraph, the previous paragraph is generated cyclically, and another paragraph is generated cyclically, the text I want to add cannot be placed in a loop, but can only be added after the text is output twice. how can I do this...
To export a Word document, add the text to the specified position of the document. for example, after the previous paragraph, the previous paragraph is generated cyclically, and another paragraph is generated cyclically, the text I want to add cannot be placed in a loop, but can only be added after the text is output twice. how can I output the text to the next first loop?
For example:
I want to put the answer behind the question, and the question and option are generated cyclically. how can I put it behind the "sanction ??
Please enlighten me
Some code:
Foreach ($ ques ['answer'] as $ key = >an an) {$ textrun1 = $ section-> createTextRun ('rstyle '); if (is_array ($ an ['synopsis ']) {$ textrun1-> addText ($ this-> aZ [$ key]. ". ", 'rstyle'); foreach ($ an ['synopsis '] as $ I) {if (isset ($ I ['type']) & $ I ['type'] = "text") {$ textrun1-> addText ($ I ['value'], 'rstyle ');} if (isset ($ I ['type']) & $ I ['type'] = "img" & file_exists ($ img = ROOT_DIR. str_replace (ROOT_UR L, '', $ I ['value']) {$ imageStyle = array ('width' => $ I ['width'] = 0? 350: $ I ['width'], 'height' => $ I ['height'] = 0? 350: $ I ['height'] // 'align '=> 'center',); $ textrun1-> addImage ($ img, $ imageStyle );}} unset ($ textrun1);} else {$ section-> addText (strtoupper ($ this-> aZ [$ key]). ". ". $ an ['synopsis '], 'rstyle');} if ($ an ['value']) {$ answer [] = $ this-> aZ [$ key] ;}$ section-> addTextBreak () ;}// determine whether to output the answer if ($ withAnswer = 1) {$ section-> addText ("(". implode ($ answer ,","). ")", 'rstyle'); $ section-> addTextBreak (); $ answer = array ();}
Reply content:
To export a Word document, add the text to the specified position of the document. for example, after the previous paragraph, the previous paragraph is generated cyclically, and another paragraph is generated cyclically, the text I want to add cannot be placed in a loop, but can only be added after the text is output twice. how can I output the text to the next first loop?
For example:
I want to put the answer behind the question, and the question and option are generated cyclically. how can I put it behind the "sanction ??
Please enlighten me
Some code:
Foreach ($ ques ['answer'] as $ key = >an an) {$ textrun1 = $ section-> createTextRun ('rstyle '); if (is_array ($ an ['synopsis ']) {$ textrun1-> addText ($ this-> aZ [$ key]. ". ", 'rstyle'); foreach ($ an ['synopsis '] as $ I) {if (isset ($ I ['type']) & $ I ['type'] = "text") {$ textrun1-> addText ($ I ['value'], 'rstyle ');} if (isset ($ I ['type']) & $ I ['type'] = "img" & file_exists ($ img = ROOT_DIR. str_replace (ROOT_UR L, '', $ I ['value']) {$ imageStyle = array ('width' => $ I ['width'] = 0? 350: $ I ['width'], 'height' => $ I ['height'] = 0? 350: $ I ['height'] // 'align '=> 'center',); $ textrun1-> addImage ($ img, $ imageStyle );}} unset ($ textrun1);} else {$ section-> addText (strtoupper ($ this-> aZ [$ key]). ". ". $ an ['synopsis '], 'rstyle');} if ($ an ['value']) {$ answer [] = $ this-> aZ [$ key] ;}$ section-> addTextBreak () ;}// determine whether to output the answer if ($ withAnswer = 1) {$ section-> addText ("(". implode ($ answer ,","). ")", 'rstyle'); $ section-> addTextBreak (); $ answer = array ();}
Solved. TextRun is used to represent the text to be connected together with the same textrun object.