How to create a user with field collections programmatically?
I think following code should give you an idea.

    //Create a field collection entity
    $field_collection_item = entity_create('field_collection_item', array('field_name' =&gt; 'field_personal_details'));
    $field_collection_item-&gt;field_firstname[LANGUAGE_NONE][0]['value'] = "Yassin Tahtah";        
    //$field_collection_item-&gt;field_firstname['und'][0]['value'] = "Yassin Tahtah";
    $field_collection_item-&gt;setHostEntity('user', $user);
    // Save the entity.
    $field_collection_item-&gt;save(TRUE);