Announcement

Collapse
No announcement yet.

how do i replace summin with a file?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • how do i replace summin with a file?

    i need to replace a word with the contents of a file but i dont know how

    i tried:


    PHP Code:
    $string="hehefhrhnewsiorfji";
    $news=file("news.php");
    $string=str_replace("news",$news,$string);
    echo 
    $string
    but had no luck


    TIA

  • #2
    file() returns an array, not a string.

    $news=implode('', file("news.php"));

    Comment


    • #3
      thanx man, this forum shud be called the "max albert forum"

      Comment


      • #4
        i 4got to mention that news.php contains php code that needs to be executed, sorry

        its now printing the file contents instead of actually showing the html output of news.php, if ya get me

        Comment


        • #5
          try something like this:
          PHP Code:
          $string "hehefhrhnewsiorfji";
          $news implode(''file("http://www.example.com/path/to/news.php"));
          $string str_replace("news"$news$string);
          echo 
          $string
          If news.php needs any variables from this script, you will need to send it in a querystring in the file() call.

          Comment

          widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
          Working...
          X