目前我有一個字符串,它拉出一個帖子的標題,幷包括文件的數量mb將返回一堆數字。替換數字1的值 - 20
下面是我們通常拉帖子的內容(這是所有保存到一個字符串)
<a href="http://example.com/a0j8nm5l3wo0" target=_blank>01 song name.mp3 - 2.4 MB</a>
<a href="http://example.com/ic1jfhhzzfth" target=_blank>02 song name.mp3 - 4.0 MB</a>
<a href="http://example.com/zo2nv6bzy6gd" target=_blank>03 song name.mp3 - 3.3 MB</a>
<a href="http://example.com/5fyony1m4j0w" target=_blank>04 song name.mp3 - 3.5 MB</a>
<a href="http://example.com/3imswet27clg" target=_blank>05 song name.mp3 - 1.9 MB</a>
<a href="http://example.com/ml65j3gpdggv" target=_blank>06 song name.mp3 - 3.4 MB</a>
<a href="http://example.com/hmuk8il0a04j" target=_blank>07 song name.mp3 - 4.4 MB</a>
<a href="http://example.com/qx81e67ystd3" target=_blank>08 song name.mp3 - 3.9 MB</a>
<a href="http://example.com/g6fo1s64vzkj" target=_blank>09 song name.mp3 - 3.9 MB</a>
<a href="http://example.com/xo3hw4xyx372" target=_blank>10 song name.mp3 - 3.6 MB</a>
<a href="http://example.com/ivcth22eqygd" target=_blank>11 song name.mp3 - 3.3 MB</a>
因爲我敢肯定有人要問我是如何轉換的值入一個字符串,數據存儲在WordPress the_content
中,我將其轉換爲數組。
$string = get_the_content();
$links = explode("\n",$string);
$arrlength = count($links);
我怎樣才能讓這個總是刪除MB計數?我不能爆炸期間,或破折號,因爲有時軌道包括那些。
也許你可以用空值 –
替代甲基溴這將幫助: https://stackoverflow.com/questions/1445506/get-content-between-two-strings-php –