@@ -295,7 +295,7 @@ public function generate($tableData = null)
295295
296296 // Is there a table heading to display?
297297 if (! empty ($ this ->heading )) {
298- preg_match ('/(<)(td|th)/i ' , $ this ->template ['heading_cell_start ' ], $ valueHead );
298+ preg_match ('/(<)(td|th)(?=\h|>) /i ' , $ this ->template ['heading_cell_start ' ], $ valueHead );
299299 $ strHeading = count ($ valueHead ) === 3 ? $ valueHead [1 ] . $ valueHead [2 ] : null ;
300300
301301 $ out .= $ this ->template ['thead_open ' ] . $ this ->newline . $ this ->template ['heading_row_start ' ] . $ this ->newline ;
@@ -304,8 +304,8 @@ public function generate($tableData = null)
304304 $ temp = $ this ->template ['heading_cell_start ' ];
305305
306306 foreach ($ heading as $ key => $ val ) {
307- if ($ key !== 'data ' ) {
308- $ temp = $ strHeading ? str_replace ($ strHeading , $ strHeading . ' ' . $ key . '=" ' . $ val . '" ' , $ temp ) : $ temp ;
307+ if ($ key !== 'data ' && $ strHeading !== null ) {
308+ $ temp = str_replace ($ strHeading , $ strHeading . ' ' . $ key . '=" ' . $ val . '" ' , $ temp );
309309 }
310310 }
311311
@@ -359,7 +359,7 @@ public function generate($tableData = null)
359359 // Any table footing to display?
360360 if (! empty ($ this ->footing )) {
361361 // Check if there is a th or td tag, null if not
362- preg_match ('/(<)(td|th)/i ' , $ this ->template ['footing_cell_start ' ], $ valueFoot );
362+ preg_match ('/(<)(td|th)(?=\h|>) /i ' , $ this ->template ['footing_cell_start ' ], $ valueFoot );
363363 $ strFooting = count ($ valueFoot ) === 3 ? $ valueFoot [1 ] . $ valueFoot [2 ] : null ;
364364
365365 $ out .= $ this ->template ['tfoot_open ' ] . $ this ->newline . $ this ->template ['footing_row_start ' ] . $ this ->newline ;
@@ -368,8 +368,8 @@ public function generate($tableData = null)
368368 $ temp = $ this ->template ['footing_cell_start ' ];
369369
370370 foreach ($ footing as $ key => $ val ) {
371- if ($ key !== 'data ' ) {
372- $ temp = $ strFooting ? str_replace ($ strFooting , $ strFooting . ' ' . $ key . '=" ' . $ val . '" ' , $ temp ) : $ temp ;
371+ if ($ key !== 'data ' && $ strFooting !== null ) {
372+ $ temp = str_replace ($ strFooting , $ strFooting . ' ' . $ key . '=" ' . $ val . '" ' , $ temp );
373373 }
374374 }
375375
0 commit comments