Support » Plugin: Post Kinds » Quick PHP warning fix

  • peterjanes

    (@peterjanes)


    
    if ( is_array( $photos ) ) {
    	$first_photo = array_pop( array_reverse( $photos ) );
    }
    

    causes a PHP Strict warning about passing by reference. I believe this is equivalent and supported in all PHP releases:

    
    if ( is_array( $photos ) && count( $photos ) > 0 ) {
    	$first_photo = array_values( $photos )[0];
    }
    
    • This topic was modified 1 year ago by  peterjanes. Reason: code formatting
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Quick PHP warning fix’ is closed to new replies.