Creating a script that receives info and skips blank inputs

I’m creating a php script for a charity client and I’m doing it for free. :o

Here’s the scenario.

They are a Radio Station in Ireland. Their broadcast system injects code into a popout player I’m creating.
The information it outputs includes current track info and past tracks info and this is where i need help.

The system outputs all the music track info and it outputs blank entries for every ad break, audio link or news break which results in some entries on the webpage being blank. You can see it in action here: (tried to post link but system wouldn’t let me.)

What I need to do is to create a PHP script that does the following:
#Create a list of variables for each piece of information.
#Then for each variable it needs to :
# Check if each variable is set
# If not do nothing and move on to the next variable
# If set then create a new variable with info that it been given. eg $RecentTrackTitle01
# It then needs to go through each of the original variables and do the same thing but add the next number to the new variable eg: $RecentTrackTitle02 $RecentTrackTitle03 $RecentTrackTitle04

I don’t know how to make the script create a list of 5 new variables, ignoring the blanks and moving on to the next with the appropriate next number in the sequence.

Here’s what I’ve got so far:

[php]

<?php $OCP_SPECIAL_SHOWTITLE = ''; $OCP_NOW_ITEMNAME = ''; $OCP_NEXT_ITEMNAME = ''; $OCP_PREVIOUS_ITEMNAME = ''; $OCP_PREV02_ITEMNAME = ''; $OCP_PREV03_ITEMNAME = ''; $OCP_PREV04_ITEMNAME = ''; $OCP_PREV05_ITEMNAME = ''; $OCP_PREV06_ITEMNAME = ''; $OCP_PREV07_ITEMNAME = ''; ?> <?php if (empty($OCP_PREVIOUS_ITEMNAME)) {} else { $RecentTrackTitle01 = &$OCP_PREVIOUS_ITEMNAME; } ?>

[/php]

Any help greatly apprciated

Well, your code is sort of working, but, this section is invalid:

[php]
if (empty($OCP_PREVIOUS_ITEMNAME)) {}

else
{
$RecentTrackTitle01 = &$OCP_PREVIOUS_ITEMNAME;
}
[/php]
As you see, you create an IF clause, but it ends with nothing happening.
Then, you continue with the ELSE. So, that will not work.

Here is a sample of how the IF clause should work…
Basically…
if (some condition) {
something happens…
} else {
something else happens…
}
So, using that format, your code should be more like this:
[php]
if (empty($OCP_PREVIOUS_ITEMNAME))
{ // Nothing happens here of course, but, you need the braces…
} else {
$RecentTrackTitle01 = &$OCP_PREVIOUS_ITEMNAME;
}
[/php]

Hope that helps… By the way, W3-Schools have tons of simple tutorials on just about EVERYTHING.
Being a beginner, you might want to look thru them as you progress along with your project…
Or, of course, just ask here… Heres a link to their site about IF usage…
http://www.w3schools.com/php/php_if_else.asp

Sponsor our Newsletter | Privacy Policy | Terms of Service