scottybwoy Posted January 10, 2008 Share Posted January 10, 2008 This function is part of my template class... (Yeah, yeah, I know the arguments.. But this is for uploading to a flat file site). <? function ReplaceStatic($tcontent, $static_data) { foreach ($static_data as $k => $v) { if (is_array($v)) { $prefix = $k; $rowbegin = "<!--%" . $prefix . "_ROWBEGIN%-->"; $row_b_len = strlen($rowbegin); $startrow = strpos($tcontent, $rowbegin); $rowend = "<!--%" . $prefix . "_ROWEND%-->"; $row_e_len = strlen($rowend); $endrow = strpos($tcontent, $rowend) + $row_e_len; $rowlen = $endrow - $startrow; $row = substr($tcontent, $startrow, $rowlen); $subrowlen = ($endrow - $row_e_len) - ($startrow + $row_b_len); $row_content = substr($tcontent, $startrow + $row_b_len, $subrowlen); $nrow_content = "$row_content\r\n"; $rowsyntax = "<!--%" . $prefix . "_ROW%-->"; foreach ($v as $nv) { $rows .= str_replace($rowsyntax, $nv, $nrow_content); } $tcontent = str_replace($row, $rows, $tcontent); unset($rows); } else { $placeMat = "<!--%$k%-->"; $tcontent = str_replace($placeMat, $v, $tcontent); } } return $tcontent; } ?> Now the actual functionality works fine, however the returned $tcontent is repeated a number of times and when written to the file, comes out as so. Can anyone see why? Thanks Link to comment https://forums.phpfreaks.com/topic/85334-solved-please-check-this-function/ Share on other sites More sharing options...
scottybwoy Posted January 10, 2008 Author Share Posted January 10, 2008 An example of the output can be found here : http://www.mri.co.uk/controllers/eSATA-4MCR.php Bare in mind the header etc is not included it's just the content part of the page. It's also worth noting that it is placing 8 $vars and 2 $arrays Link to comment https://forums.phpfreaks.com/topic/85334-solved-please-check-this-function/#findComment-435441 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.