のもう 1 つの問題として、次のデータを先頭とダッシュ (-) の後の数字の間をとって URLstr_replace
に変更したいと思います。$title
$string
- シカゴ
'
の公立学校- $10.3M - ニュージャージー- 300万ドル
- ミシガン州: 公衆衛生- 100 万ドル
欲望の出力は次の
とおり
です
。
私が使用しているPHPコード
$title = ucwords(strtolower(strip_tags(str_replace("1: ", "", $title))));
$x = 1;
while ($x <= 10) {
$title = ucwords(strtolower(strip_tags(str_replace("$x: ", "", $title))));
$x++;
}
$link = preg_replace('/[<>()!#?:.$%\^&=+~`*é"\']/', '', $title);
$money = str_replace(" ", "-", $link);
$link = explode(" - ", $link);
$link = preg_replace(" (\(.*?\))", "", $link[0]);
$amount = preg_replace(" (\(.*?\))", "", $link[1]);
$code_entities_match = array(''s', '"', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '+', '{', '}', '|', ':', '"', '<', '>', '?', '[', ']', '', ';', "'", ',', '.', '_', '/', '*', '+', '~', '`', '=', ' ', '---', '--', '--');
$code_entities_replace = array('', '-', '-', '', '', '', '-', '-', '', '', '', '', '', '', '', '-', '', '', '', '', '', '', '', '', '', '-', '', '-', '-', '', '', '', '', '', '-', '-', '-', '-');
$link = str_replace($code_entities_match, $code_entities_replace, $link);
$link = strtolower($link);
残念ながら、私が得た結果:
-chicagoamp9s-public-school
2-new-jersey
3-michigan-public-health
誰にもこれに対するより良い解決策がありますか? みんなありがとう!
(が amp9に'
変更されました - なぜだろうか? )