Complete newbie to programming :)

i'm fiddling around having a WordPress theme striking a roadblock. Basically put this in archive.php,

<?php 

if (is_category(array( 9, 13, 24,)) {
 echo 'Light is GREEN';
  }else {
 echo 'Light is RED}';
 ?>

That part works fine, after i visit category 9, 13, 24 i recieve "light is Eco-friendly" and "light is red-colored" for those other groups.

Now i've this function which will get the id's of groups from theme options where i have to echo "light is eco-friendly"

function am_get_cat_layout_ids()
{

                global $am_option;
                $catnumend = $am_option['main']['category_onecolumn_hidden']-1;
                for($i=0; $i<$catnumend; $i++)
                {

                    $value = $am_option['main']['category_onecolumn_'.$i].',';


                }

                return $value;
}

basically echo $value rather than return, i recieve the course id's say 2, 15, 7, 34, fine but when i actually do this :

  <?php 

if (is_category(array(am_get_cat_layout_ids())) {
 echo 'Light is GREEN';
  }else {
 echo 'Light is RED}';
 ?>

it is not working.

anything that you can do to really make it work?

Thanks , Srik

What you earn is definitely an array that contains one string, that has comma-separated amounts. You need to build a range of amounts.

function am_get_cat_layout_ids()
{
    global $am_option;

    $ids = array(); // create array
    $catnumend = $am_option['main']['category_onecolumn_hidden']-1;

    for($i=0; $i<$catnumend; $i++)
    {
        $ids[] = $am_option['main']['category_onecolumn_'.$i]; // add value to array
    }
    return $ids; // return array
}

Your original code was the same for this:

if (is_category(array( "9, 13, 24,")) {

Whereas this new code may be the equal to the code at the outset of the question:

if (is_category(am_get_cat_layout_ids()) {

In case your am_get_cat_layout_ids() function returns 2, 15, 7, 34, then you want to do:

if (is_category(explode(', ',trim(am_get_cat_layout_ids(),','))) {
 echo 'Light is GREEN';
  }else {
 echo 'Light is RED}';

Do this:

function am_get_cat_layout_ids()
{
    global $am_option;
    $ret = array();
    $catnumend = $am_option['main']['category_onecolumn_hidden']-1;

    for($i=0; $i<$catnumend; $i++)
    {
            $ret[] = $am_option['main']['category_onecolumn_'.$i];
    }

    return $ret;
}

and

if (is_category(am_get_cat_layout_ids()) {
    echo 'Light is GREEN';
}else {
    echo 'Light is RED}';
}