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.

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

报告相同问题?

悬赏问题

  • ¥100 数字取证课程 关于FAT文件系统的操作
  • ¥15 如何使用js实现打印时每页设置统一的标题
  • ¥15 安装TIA PortalV15.1报错
  • ¥15 能把水桶搬到饮水机的机械设计
  • ¥15 Android Studio中如何把H5逻辑放在Assets 文件夹中以实现将h5代码打包为apk
  • ¥15 使用小程序wx.createWebAudioContext()开发节拍器
  • ¥15 关于#爬虫#的问题:请问HMDB代谢物爬虫的那个工具可以提供一下吗
  • ¥15 vue3+electron打包获取本地视频属性,文件夹里面有ffprobe.exe 文件还会报错这是什么原因呢?
  • ¥20 用51单片机控制急停。
  • ¥15 孟德尔随机化结果不一致