星期三 , 22 1 月 2025

array_key_existsPHP检查数组里是否有这项


$args = ['post_subtitle','postType','pageUrl']; 

	foreach ($args as $arg) { 
		if (array_key_exists($arg, $_POST)) {
			update_post_meta( $post_id, $arg, sanitize_text_field( $_POST[$arg] ) );
			
		}
		
		
	}