SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Wizard Zaggs's Avatar
    Join Date
    Feb 2005
    Posts
    1,045
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Is there a shorter way to do this?

    Hi Guys!

    I was wondering if there was a quicker way to do what I have done below (maybe using array_map?). Any help is appreciated.

    PHP Code:
    if(!empty($array['skills']['skill']))
                        {
                            
    $skill_array = array();
                            
                            foreach(
    $array['skills']['skill'] as $key=>$value)
                            {
                                
    $skill_array[] = $array['skills']['skill'][$key]['skill']['name'];
                            }
                            
    $_SESSION['linkedin_data']['skills'] = implode(', ',$skill_array);
                        } 
    Thanks.

  2. #2
    SitePoint Wizard wonshikee's Avatar
    Join Date
    Jan 2007
    Posts
    1,223
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    I see nothing wrong with it.

    Only thing I would of done differently is

    $skill_array[] = $value['skill']['name'];

    But it's just cuz that uber long array spams "skill" too many times for my taste


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •