次のように、ある文字列を別の文字列内で使用したいと思います。
$url = " http://www.sample.com/index.php?nr= $string[0]";
この文字列を最後に挿入するにはどうすればよいですか?
次のように、ある文字列を別の文字列内で使用したいと思います。
$url = " http://www.sample.com/index.php?nr= $string[0]";
この文字列を最後に挿入するにはどうすればよいですか?
問題の解決策として、次のコード スニペットを実行してみてください。
ドット演算子(.)を使用してphpで文字列を連結する必要があります
$url = "http://www.sample.com/index.php?nr=".$string[0];
$url = "http://www.sample.com/index.php?nr={$string[0]}";
また
$url = "http://www.sample.com/index.php?nr=" . $string[0];
あなたの例のように
$url = "http://www.sample.com/index.php?nr=$string[0]";