Hi I'm not good using PHP, and I want to use space or symbols (- / * | etc...) between each ad (I'm using 5 ads) The code on include is: <?php ini_set ("include_path", ini_get ("include_path") . ':../:../../:../../../:../../../../'); include ('ad_network.php'); echo $ad_network[0] . ' '; include ('ad_network.php'); echo $ad_network[1] . ' '; include ('ad_network.php'); echo $ad_network[2] . ' '; include ('ad_network.php'); echo $ad_network[3] . ' '; include ('ad_network.php'); echo $ad_network[4]; ?> You can see at www.anywhere-phone-rental.com Any suggestion?
Use this to add the | symbol after the 1st ad echo $ad_network[0] . ' \| '; PHP: Pipe symbol | is a operator in PHP and has a special meaning... you need to escape it using a backslash \
// $ad_network is an array. // implode is a function that 'glues' and array together with // whatever glue you specify and returns a single string. $my_glue = ' | '; // or whatever you want in between each ad. maybe <br> $all_5_ads = implode($my_glue,$ad_network); echo $all_5_ads; PHP: a pipe does not need to be escaped. anything in single quotes does not need to be escaped.
You don't even have to escape the pipe in double quotes. The fact that it is in a string means it that it won't be treated as an operator. The main things you have to escape are other (inner) single and double quotes and dollar signs.
This one needs to be stickied! Damn, this worked on another script, but now I'm getting this: "Warning: implode(): Bad arguments."
That usually means the array variable you're trying to implode is not defined or is not an array. You've included the ad_network.php file successfully? Test by trying: echo "ad_network[0]: $ad_network[0]"; PHP: