-1

I am trying to parse the php script to print contents of config file.

bar.php:

<?php

$arr = array("monday", "tuesday");

?>

mainscript.php:

<?php

function foo(){ # define function
$today = date('Y-m-d'); 
require_once( "bar.php" );
foreach ($arr as $value)
{
$foo = $value.$today ; 

echo $foo ;
}
}

foo(); # function call

?>

This is what I get:

php mainscript.php

monday2015-03-25tuesday2015-03-25

This is what I want:

monday2015-03-25
tuesday2015-03-25
Rio
  • 765
  • 3
  • 17
  • 37

1 Answers1

0

I am not sure if your approach is the best but here it goes:

<?php
function foo(){ # define function
$today = date('Y-m-d'); 
 require_once( "bar.php" );
 foreach ($arr as $value) {
    echo $value.$today."\n<br>";
 }
}
foo(); # function call
?>

Appending a <br> or a \n after each echo call would add a new line.

Hope this helps

Nikos
  • 3,267
  • 1
  • 25
  • 32