Thursday, 1 September 2022

Php filter string

 function FilterString($str)

{

     $aftertrim=trim($str);

    $afterstrip= strip_tags($aftertrim);

    $agintrim=trim($afterstrip);

    $afterremovesapce=strtolower(str_replace(" ","_",$agintrim));

    $removeSpecialChar = preg_replace('/[0-9\@\.\;\" "\?]+/', '', $afterremovesapce);

    //$strlen=strlen($removeSpecialChar);

   if(strlen($removeSpecialChar) > 23)

   {

    $checklast= substr($removeSpecialChar,0,24);

   }

    //$afterGarbageremove=gc_disable($checklast);

     $agintrim=trim($checklast);

    //$lastchar=$checklast[1];

    

    

  $lastchar= substr($agintrim, strlen($agintrim)-1);

    if($lastchar== '_')

    {

     $isexistlen=strlen($checklast);

     $finalstring=substr($checklast,0,$isexistlen-1 );

     $returnString= $finalstring;

    }else

    {

      $returnString= $agintrim;

    }

    return $returnString;

}

No comments:

Post a Comment

Laravel Export data to csv

 use Illuminate\Http\Response; // Define a function to export data to CSV function exportToCSV($exportData, $columns) {     $filename = ...