데이터베이스에서 검색하는 문자열이 있는데 공백없이 문자열의 길이를 계산하려고하지만 실제 길이보다 큰 21 개의 문자를 표시합니다. 탭과 개행 문자는 물론 php와 html 태그도 제거했지만 아무런 결과도 얻지 못했습니다! 나는 w3schools PHP 레퍼런스에서 거의 모든 기능을 시도했지만 어떤 성공도 찾을 수 없다. 나는 또한 내가 데이터베이스 입력에서 값을 검색하지 않는 경우이 좋아하는 것을 관찰 : Strlen이 올바른 출력을 제공하지 않음
$string = "my string";
if($res_tutor[0]['tutor_experience']){
$str = trim(strip_tags($res_tutor[0]['tutor_experience']));
$str = $this->real_string($str);
$space = substr_count($str, ' ');
$experience = strlen($str) - $space;
function real_string($str)
{
$search = array("\t","\n","\r\n","\0","\v");
$replace = array('','','','','');
$str = str_replace($search,$replace,$str);
return $str;
}
그리고이 데이터베이스에서 문자열하지만 strip_tags()
를 사용하여 모든 PHP와 HTML 태그를 제거한 위에 당신이 볼 수 있듯이 : 나는 그것을 인쇄 할 때
<span class=\"experience_font\">You are encouraged to write a short description of yourself, teaching experience and teaching method. You may use the guidelines below to assist you in your writing.<br />
<br />
.Years of teaching experience<br />
.Total number of students taught<br />
.Levels & subjects that you have taught<br />
.The improvements that your students have made<br />
.Other achievements/experience (Relief teaching, a tutor in a tuition centre, Dean's list, scholarship, public speaking etc.)<br />
.For Music (Gigs at Esplanade, Your performances in various locations etc.)</span><br />
</p>
을,
<span class=\"experience_font\">You are encouraged to write a short description of yourself, teaching experience and teaching method. You may use the guidelines below to assist you in your writing.<br />
<br />
.Years of teaching experience<br />
.Total number of students taught<br />
.Levels & subjects that you have taught<br />
.The improvements that your students have made<br />
.Other achievements/experience (Relief teaching, a tutor in a tuition centre, Dean's list, scholarship, public speaking etc.)<br />
.For Music (Gigs at Esplanade, Your performances in various locations etc.)</span><br />
</p>
브라우저에서 이것을 보는 경우 HTML 태그 및 기타 등이 없는지 확인하십시오. 여분의 문자를 볼 수 없기 때문에 거의 의미가 없습니다. –
여분의 태그가 있었고 strip_tags()를 사용하여 제거했습니다. – irohit786
나는 그것을 얻지 못합니다 ... 입력 한 코드를 실행했는데 나에게 잘 맞습니다. 그것은 당신이 db에서 얻은 것과 관련이 있어야합니다 ... 더 많은 코드를 추가하거나 db의 텍스트를 직접 복사하려고 시도해야합니다. – hummingBird