のようないくつかの範囲は、これが唯一である場合、ソース文字列のパターンの確認
$numbers = "23, 509, 209, 11, 139, 68, 70-72, 50, 409-412";
$output = "";
$numbers = explode(",",$numbers);//split the string into array (NOTE:only if you trust the pattern of the string)
foreach($numbers as $number){
$number = str_replace(" ","", $number); // remove the space that is after the comma if there is
$range = explode("-",$number); // if it is a range it will be splitted
$output .= "<a href='www.mysite.com?page=".$range[0]."'>$number</a> ";
}
echo $output;
HTML注:このwww.mysite.com
ようにhref属性を作成すると、ブラウザはそれはのトレイルになります現在のドキュメントの場所後の値は、私がそれを推測し、この
https://www.example.com/currentlocation/www.mysite.com?page=23
のようなものになるだろうことはあなたが望むものである
<a href='https://www.example.com?page=23'>
お試しください。 – Toto
数字をどうやって見つけたのか、数値を変数に取り込む方法が分かっていれば(あるいは数値を変数にも入れていますか?)、助けが簡単になります。 –
これを行うにはPHPまたはJavaScriptを使用する必要がありますが、HTMLだけで問題を解決することはできません –