0

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 ),
);
2
Contributors
3
Replies
24
Views
3 Years
Discussion Span
Last Post by Priti_P
0

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
        )

)

Edited by Priti_P

0

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));

Edited by DJBirdi

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.