1

jobdescription の最初の 150 文字ですべての求人を表示する求人検索ページがあります。

{$listing.JobDescription|strip_tags|truncate:150} in smarty php template file

戻ります:

Responsibilities:  1) Handle...  

これは上記のソースコードです: http://jsfiddle.net/e2ScF/126/

エディターから作成された元のテキストとサンプル テキストは、http: //jsfiddle.net/e2ScF/125/にあります。

私の質問は、次のような < p >、< br/ > などの html タグなしで求人検索結果を表示する方法です。

Responsibilities:1) Handle outbound telesales campaigns for consumer markets (for CallMark clients) by...
4

2 に答える 2

1

PHP の例を次に示します (実際の動作を参照してください)。

<?php
    $string = '<p>
    &nbsp;</p>
<table align="center" border="0" cellpadding="3" cellspacing="0" class="normalword" style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; color: rgb(0, 0, 0);" width="95%">
    <tbody>
        <tr>
            <td>
                <table align="center" border="0" bordercolor="#666666" cellpadding="3" cellspacing="0" class="normalword" width="100%">
                    <tbody>
                        <tr>
                            <td>
                                <div align="justify">
                                    Responsibilities:&nbsp;<br />
                                    <br />
                                    1) Handle outbound telesales campaigns for consumer markets (for CallMark clients) by utilizing effective presentation and creating positive relationship for all customer contacts with the aim to cross/up selling client&rsquo;s product and services.&nbsp;<br />
';

function firstXChars($string, $chars = 100)
{
    $string = trim(strip_tags($string));
    $string = str_replace(array("\n", "\r"), '', $string);
    preg_match('/^.{0,' . $chars. '}(?:.*?)\b/iu', $string, $matches);
    return $matches[0];
}

echo firstXChars($string);
于 2013-02-06T12:55:21.737 に答える
1

あなたの問題は、テキストの途中に多くの空白があるため、 truncate はそれらを 150 の制限でカウントすることです。

ストリップで試してください :

{$listing.JobDescription|strip_tags|strip|truncate:150}
于 2013-02-06T19:24:00.353 に答える