<?php
$numcpost = of_get_option('how_many_custom_posts');
do {
add_action( 'init', 'register_cpt_mdframework_price', $numcpost );
--$numcpost;
} while ( $numcpost > 0 );
function register_cpt_mdframework_price( $numcpost ) {
$singcpost = of_get_option('custom_posts_name_s_n'.$numcpost.'');
$plurcpost = of_get_option('custom_posts_name_p_n'.$numcpost.'');
$desccpost = of_get_option('custom_posts_name_d_n'.$numcpost.'');
$imgcpost = of_get_option('custom_posts_name_i_n'.$numcpost.'');
$labels = array();
// labels for $numcpost = 1
$labels[1] = array(/*typo was here*/
'name' => _x( $plurcpost, 'mdframework_custom_created_post'.$numcpost.'' ),
'singular_name' => _x( $singcpost, 'mdframework_custom_created_post'.$numcpost.'' ),
'add_new' => _x( 'Add New', 'mdframework_custom_created_post'.$numcpost.'' ),
);
// labels for $numcpost = 2
$labels[2] = array(
// ...
);
$args = array();
// args for $numcpost = 1
$args[1] = array(
'labels' => $labels[1],
'hierarchical' => true,
'description' => $desccpost,
);
// args for $numbercpost = 2
$args[2] = array(
'labels' => $labels[2]
// ...
);
register_post_type( 'mdframework_custom_created_post_'.$numcpost, $args[$numcpost] );
}
Use multidimensional arrays. Simple, isn’t it?