I'm struggling to figure out how to use PHP strpos to find a variable in a string. The code below works if I enter a number directly but not if I replace the number with a variable I know to be a single number. No PHP errors present but the conditional renders false. I've been searching all over and am stumped by this.
The $string variable returns "253,254,255".
The $current_page_id variable returns "253".
$string = "";
foreach( $page_capabilities as $post):
$string .= $post->ID.',';
endforeach;
if (strpos($string, $current_page_id) !== false) {
// This works
//if (strpos($string, '253') !== false) {
// This does not
if (strpos($string, $current_page_id) !== false) {
echo 'true';
}
}