SitePoint Sponsor

User Tag List

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

    serialize and array_map question

    Hi Guys!

    I have the following piece of code which should apply all functions to each item in the array and then serialize it. However, ucfirst() is not getting applied. All of the others are working except ucfirst(). Any ideas why?

    PHP Code:
    if(!empty($_POST['language'])){
       
    $languages serialize(
       
    array_map('strtolower'
       
    array_map('trim'
       
    array_map('ucfirst'
       
    explode(","$_POST['language'])))));


  2. #2
    SitePoint Evangelist hexburner's Avatar
    Join Date
    Jan 2007
    Location
    Belgium
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Because your mapping the array with strtolower after ucfirst...
    So it should be:
    PHP Code:
    if(!empty($_POST['language'])){
        
    $languages serialize(
            
    array_map('ucfirst'
                
    array_map('trim'
                    
    array_map('strtolower'
                        
    explode(","$_POST['language'])
                    )
                )
            )
        );

    FOR SALE: 1 set of morals, never used, will sell cheap

  3. #3
    SitePoint Wizard Zaggs's Avatar
    Join Date
    Feb 2005
    Posts
    1,048
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oops thanks


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
  •