dounuo7954 2016-11-19 00:59
浏览 19
已采纳

PHP循环页面的内容,制作并保持更改

Database generated page will be saved as static pages but the url's within the page itself needs to be rewritten. The function is already made.

-> I got an error : implode(): Invalid arguments passed

Goal : the website will be in 3 languages but they all uses the same page index.php. So that's not good enough for google. So static pages will be generated and each language will have his own folder.

While the page is extracted I'll do some url rewrite within the codes of the extracted content. (No not just an Url rewrite for .htaccess. That's not the point at all.) The pages will change name completely and becomes a static page.
I hope this is clear enough. Hope someone find a way, I tried so much I have almost lost hope to accomplish this.

//At the beginning of the page above the HTML tag. 
//Destination for the page and the new name for the page.

$cachefile = "../".trim($_GET['lang'])."/".trim($_GET['page']).".php";

ob_start();

<html>
<body>
...
</body>
</html>

 // At the end of the page
 $content = ob_get_contents();


// here the loop with my function to find an url

$content = ob_get_contents();

$arrcontent = explode(" ",$content); 

$newcontent="";

foreach($arrcontent as $value){

    $value = replaceurl_newurlmenu($value, $pathwebsite, $pathmenu);

    $newcontent .= array($value);    

}

$content =  implode(" ",$newcontent);



// then write everything to a page at a new destination

$fp = fopen($cachefile, 'w');    
fwrite($fp,  $content);    
fclose($fp);    

ob_end_flush();
  • 写回答

1条回答 默认 最新

  • douwan7382 2016-11-19 01:07
    关注

    To fix what you have

    $arrcontent = explode(" ",$content); 
    
    $newcontent=array();
    
    foreach($arrcontent as $value){
    
    $value = replaceurl_newurlmenu($value, $pathwebsite, $pathmenu);
    
    $newcontent[] = $value;    
    
    }
    
    $content =  implode(" ",$newcontent);
    

    But I would consider looking at array_walk method too.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 TLS1.2协议通信解密
  • ¥40 图书信息管理系统程序编写
  • ¥20 Qcustomplot缩小曲线形状问题
  • ¥15 企业资源规划ERP沙盘模拟
  • ¥15 树莓派控制机械臂传输命令报错,显示摄像头不存在
  • ¥15 前端echarts坐标轴问题
  • ¥15 ad5933的I2C
  • ¥15 请问RTX4060的笔记本电脑可以训练yolov5模型吗?
  • ¥15 数学建模求思路及代码
  • ¥50 silvaco GaN HEMT有栅极场板的击穿电压仿真问题