Forum

Thread tagged as: Question, Api

Testing for string fails?

Hi,

I have a SELECT in the Admin side of Perch and choose the option house.

In a page I attempt to detect when it's matched with

$fred = perch_content_custom('slide_show');

echo $fred;

if (strpos($fred,'house') !== false) {
    echo 'true';
}

but the test never matches.

Quick check—is there something obvious I'm doing wrong? Thanks in advance for any pointers.

Alan Bristow

Alan Bristow 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

$fred = perch_content_custom('slide_show', [], true);

Thanks a ton Drew, works of course.

I had tried this from the docs but it failed:

$fred = perch_content_custom('slide_show', true);

(is your version documented on a different page?)

Cheers, -Alan

Drew McLellan

Drew McLellan 2638 points
Perch Support

The docs are for perch_content()

<?php $my_var = perch_content('Intro', true); ?>

Thanks Drew.

[staring blankly at screen in disbelief] —I tried exactly this syntax and it didn't work... I clearly need to drink a different amount of coffee and sorry for troubling you. Cheers, -Alan