How can Remove all special characters from a string using php

function clean($string) {

$string = str_replace(' ', '-', $string); // Replaces all spaces with hyphens.

return preg_replace('/[^A-Za-z0-9\-]/', '', $string); // Removes special chars.


echo clean('a|"bc!@┬úde^&$f g hij|!##');  // abcdefghij

echo clean('&&&week_!-15 95 497739.jpg'); // week1595497739

View More...

How to upload file on AWS S3 Bucket using Rest API

#Step1: Create Aws3 class which file path application/libraries/Guzzlehttp.php

Source Code:

<?php if (!defined('BASEPATH')) exit('No direct script access allowed');


use GuzzleHttp\Client;

class Guzzlehttp{

     public function __construct(){

          $this->client = new \GuzzleHttp\Client();


    public function sendMultiForm($end_point_url, $multipart){

          return $this->client->request('POST', $end_point_url, [ 'multipart' => $multipart ]);


    public function sendForm($end_point_url, $form_params){

        return $this->client->request('POST', $end_point_url, ['form_params' =>$form_params]);



#Step2: load library in Controller

class Product_Api extends CI_Controller


      public function __construct()






    public function addProductImage()



       $image_abs_path = 'uploads/products/'.$product_id.'/'.$img1_nm;



            ['name' => 'file_path_name','contents' =>$image_abs_path],

            ['name' => 'image_url', 'contents' => fopen($image_abs_path, 'r')]


     $response=$this->guzzlehttp->sendMultiForm($end_point_url, $multipart);

    // echo $body = $response->getBody();


View More...