Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.
$formpage=implode(unserialize(get_option('_formpages[]')),",");
if (is_page(array($formpage))) {
echo '<link href="'.THEMEURI.'/forms.css" rel="stylesheet" type="text/css" />
'; } 

I need to find a way to print or echo or get the array pages in the "is_page"... It works fine if I echo it in the link CSS - the 3 page IDs get added as raw text. I actually want to fnd a way to get those page IDs in the array:

if (is_page(array('44,56,29'))) {

Any help would really great guys. Thanks!

share|improve this question

closed as off topic by toscho Feb 17 at 22:46

Questions on WordPress Answers are expected to relate to WordPress within the scope defined in the FAQ. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about closed questions here.

1 Answer

If I'm understanding your question correctly, you can use explode to turn the comma-delimited string into an array.

Consider the following:

$string = "44,56,29";
$array = explode(',', $string);

Now, you have an array that looks like this:

[0] => "44",
[1] => "56",
[2] => "29"

If you want to go the extra mile, you can loop through them again using a for loop to cast them as integers instead of strings.

for ($i = 0; $i < count($array); $i++)
    $array[$i] = (int)$array[$i];

And magically, your array is now this:

[0] => "44",
[1] => "56",
[2] => "29"

I really hope I understood your question and that this helps you. If not, sorry I wasted your time.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.