ACK! str_replace and arrays not working?
From: Joel C Bennett (JoelCBennett_at_gmail.com)
Date: 10/06/04
- Previous message: Alphajet: "php 5.02 session problems (I did look for it before asking)"
- Next in thread: Paul Barfoot: "Re: ACK! str_replace and arrays not working?"
- Reply: Paul Barfoot: "Re: ACK! str_replace and arrays not working?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 6 Oct 2004 14:58:25 -0700
I am attempting to replace in an array (read in from a text file)
wherever a "<j>" appears with the contents of a different array
(filled from a different text file). It is returning "Array". What
am I doing wrong?
here is the code:
//load text files into variables
$formFile = "main.txt";
$studInfoFile = "studinfo.txt";
$rbJavaFile = "rbjava.txt";
$stJavaFile = "test.txt";
$rbFormFile = "rbform.txt";
$testFile = "test.txt";
//supress errors with @ and load text files into variables
if (!$form = @file($formFile, 'r')) {
fail("Cannot open file: " . $formFile . "!");
}
if (!$studInfo = @file($studInfoFile, 'r')) {
fail("Cannot open file: " . $studInfoFile . "!");
}
if (!$rbjava = @file($rbJavaFile, 'r')) {
fail("Cannot open file: " . $rbjavaFile . "!");
}
if (!$stJava = @file($stJavaFile, 'r')) {
fail("Cannot open file: " . $stJavaFile . "!");
}
if (!$rbForm = @file($rbFormFile, 'r')) {
fail("Cannot open file: " . $rbFormFile . "!");
}
$newForm = str_replace("<j>",$stJava,$form);
foreach ($newForm as $line) {
echo "$line\n";
}
- Previous message: Alphajet: "php 5.02 session problems (I did look for it before asking)"
- Next in thread: Paul Barfoot: "Re: ACK! str_replace and arrays not working?"
- Reply: Paul Barfoot: "Re: ACK! str_replace and arrays not working?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]