I have array of keys.

$all_skills2= CHtml::listData(Skill::model()->findAll(array('order' => 'skill')),'skill_id','skill');
$database = array_fill_keys($all_skills2,'');

this array looks like:

    Array
(   [Android] => 
    [ax] => 
    [bbb] => 
    [Big Data] => );

now i want to fill values to this array.
where values are in another array $skill_type_count
which i got from below code:

$all_skillTypes= CHtml::listData(SkillType::model()->findAll(array('order' => 'skill_type_id')),'skill_type_id','skill_type_id');
$GS_ids=array();
$skill_type_count=array();

    foreach($all_skillTypes as $all_skillTypes_)
    {
        $all_skills=CHtml::listData(Skill::model()->findAll(array('order'=>'skill_id','condition' =>'skill_type_id='.$all_skillTypes_)),'skill_id','skill_id');
        foreach($all_skills as $all_skills_key =>$all_skills_value)
        {
            $results=CHtml::listData(EmployeeSkillSet::model()->findAll(array('condition' => 'skill_id='.$all_skills_value)),'uid','skill_id');
            $count_of_skill=count($results);
            array_push($skill_type_count, array("SKILL_ID"=>$all_skills_value,"weight"=>$count_of_skill));
        }       
    }

FYI: $skill_type_count looks like:

Array
(  [0] => Array
        (
            [SKILL_ID] => 1
            [weight] => 12
        )
    [1] => Array
        (
            [SKILL_ID] => 22
            [weight] => 44
        )
    [2] => Array
        (
            [SKILL_ID] => 73
            [weight] => 3
        )
    [3] => Array
        (
            [SKILL_ID] => 84
            [weight] => 51
        ))

I want to put these values of $skill_type_count to $database ' keys.

How can I?
In short I want array like:

    Array
(   [Android] => array(['SKILL']=>1 ,['weight']=>12 ),
    [ax] => array(['SKILL']=>22 ,['weight']=>44 ),
    [bbb] => array(['SKILL']=>73 ,['weight']=>3 ),
    [Big Data] => array(['SKILL']=>84 ,['weight']=>51 ),
);

I tried like
$array = array_combine($database,$skill_type_count);
but it gives me only last value and without key value
as below:

Array
(
    [] => Array // NO KEY HERE??
        (
            [SKILL_ID] => 117
            [weight] => 1
        )

)

Since both your arrays are setup as $key => $value pairs, you have to explicitly tell array_combine which array to use for what. This should work:

$array = array_combine(array_keys($database), array_values($skill_type_count));

Thats great!!
thanks!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.