i've got the folowing code.

$coauthors = get_post_meta( $post_id, "coAuthors" );

print_r($coauthors);

ok derive from print_r is

Array ( [0] => 78 ) Array ( [0] => 78 )

now my user id is 78 therefore it should return true using the follow code however it does not.

$key = array_search( 78, $coauthors );

     if($key) { 

     return true;

     }else{

     echo "no"; 

     }

So why do i usually get no where shall we be held failing what the easiest method to do that???

Thanks

Im still getting issues here's my function.

   add_action('is_true','isdAuthorTrue');

    function isdAuthorTrue( $post_id ) { 

        $current_user = wp_get_current_user();
    if ( !($current_user instanceof WP_User) )
    return;

        $current_user = wp_get_current_user();

         $coauthors = get_post_meta( $post_id, "coAuthors" );

         $key = array_search( $current_user->ID, $coauthors );
         $key = 0;
         if($key !== false) {

           return true;

         } else {

             return false;
         }


        }  

after which i'm attempting to run this informed.

if(do_action( 'is_true', $post->ID )){

    echo "yes";

}else{

    echo "no";
}

help???

Within this example, the important thing value is going to be because that's the index within the array where 78 is really a value. Thus states if($key) will fail when $key = , even when $secret is a legitimate array index.

To check on for validity, what you need to do is one thing such as the following

if (in_array(78, $coauthors)) {
    $key = array_search(78, $coauthors);
    // do what you want with $key and the $coauthors array
}
$key = 0;

That leads to false.

You can examine for key such as this:

if($key !== false) {
    // do sth with it
} else {
    // does not exist
}

Because no entry in $coauthors has got the value 78. $coauthors is a range of arrays, and among the sub-arrays has got the value 78 inside it.

So you'd have to search all of the sub-arrays.

edit: hm, you sure your print_r produces a printout that appears like this? Looks odd...