PHP는

2011-01-27 11 views
1

내가 실제 단어를 제외한 모든 트림하려고 공간을 트리밍하지 트림 그래서이 워드 프레스 기능을 가지고PHP는

이 형식

[email protected] 

에 반환하지만이 같은 반환해야

the_author_meta('author_image', $_GET['author']); 

             [email protected]     
공백 수톤

난이

시도
<?php print trim($matching_image, "\n"); exit; ?> 

<?php print trim($matching_image); exit; ?> 

모두는 여전히 HTML 여기

내 전체 기능을

<?php $matching_image = the_author_meta('author_image', $_GET['author']); ?> 
<?php print trim($matching_image, "\n"); exit; ?> 
<div class="post" id="post-<?php the_ID(); ?>"> 
<?php if (is_numeric($matching_image)){ ?> 
<img src="/wp-content/authors/missing.jpg" alt="<?php the_author(); ?>" title="<?php the_author(); ?>" /> 
<?php }else{ ?> 
<img src="/wp-content/authors/<?php print $matching_image; ?>" alt="<?php the_author(); ?>" title="<?php the_author(); ?>" /> 
<?php } ?> 
+4

당신은 공간이 실패한'트림()'에서 오는 확신합니까? 'print '~'와 같은 추가 문자를 추가하십시오. trim ($ matching_image, "\ n"). "~"다른 곳에서 오지 않는지 확인하십시오. – Maerlyn

+2

공백이 맞습니까? 어떤 식 으로든 그들은  과 같은 것이 될 수 있습니까? – wajiw

답변

1

것이 도움이됩니다에 공간을 갖고있는 것 같다? 하나

$matching_image = preg_replace("/^(\\s)*\|(\\s)*$/","$2",$matching_image); 
0

설명

$matching_image = preg_replace("/^(\\s)*|(\\s)*$/","$2",$matching_image); 

또는이 아마 당신은 비 분리 공백으로 다루고 있다는 점이다. 이, 나를 위해 완벽하게 작동 해보십시오 :

trim($matching_image, chr(160)); // 160 is ASCII code for non-breaking space