Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to remove blank spaces from Request using recursive in CakePHP

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 621
    Comment on it

    Removing the white spaces from a string is a easy task, but for doing this in whole of you website you need the recursive function in Cakephp

    The 'array_walk_recursive()' will recursively get the request(GET/PUT) data and remove the white/blank spaces

    for example

     if ($this->request->is('post') || $this->request->is('put')) {
                array_walk_recursive($this->request->data, array($this, 'trimArray'));
            }
    
    
    
    // Remove white spaces from start and end of a string from element
        public function trimArray(&item, &key)
        {
            $item = trim($item);
        }
    

    Now your all request data will have zero white spaces

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: