I am trying to compare two string but it always return false . Both strings are same but when I checked it further got to know that one is in utf-8 ( coming from database/eloquent ) and other being submitted from form ( ancii ) . Main issue is that in databse there are spaces between and after string . I also tried to use mysql TRIM() but failed . Any lead what should I do ?
I also tried to change encoding with
iconv("UTF-8", "ISO-8859-1",str_replace(' ', '', $request->sentence))
Tried comparing string with strcmp() but it never returns 0
Any help is appreciated and thanks for paying attention .
$sentence = AvailableSentence::
where('sentence_id', $request->sentence_id)
->with(['details'])
//->where
->first();
//var_dump(strcmp( str_replace(' ', '', $sentence->details->sentence) , str_replace(' ', '', $request->sentence) ));
//var_dump( iconv("UTF-8", "ISO-8859-1",str_replace(' ', '', $request->sentence)) );
//var_dump(mb_detect_encoding(' ', '', $sentence->details->sentence));