0

これは私がJavascript/jQueryに変換しようとしているPHPコードです。何か案は?

$root_folder = 'es';
$url = "http://domainNamehere.com/event/test-event-in-the-future/";

$p = strpos($url, '/', 8);
$url_new = sprintf('%s/%s/%s', substr($url, 0, $p), $root_folder, substr($url, $p+1));
4

3 に答える 3

0
strpos() ~ .indexOf()
substr() ~ .substring()
sprintf() ~ +
于 2011-10-05T04:12:18.393 に答える
0
var root_folder = "es",
    url = "http://domainNamehere.com/event/test-event-in-the-future/",
    url_new = "",
    path_finder = /^(((http)s?:)?\/\/[^\/]+\/)/i;

url_new = url.replace(path_finder, "$1" + root_folder + "/");
于 2011-10-05T04:16:28.437 に答える
0

PHP.jsは、多くの一般的な PHP 関数の JavaScript への移植を提供します。

于 2011-10-05T04:21:26.290 に答える