我寫了這段代碼來查看設置爲私人的個人資料圖片。但是每次我必須訪問它時,我都必須在XAMPP上啓用Apache。而且,在沒有安裝Apache的計算機上它幾乎沒有用處。所以我想用JavaScript編寫它,但找不到strstr()
函數的等價物。PHP的strstr()等效於JavaScript
有人請讓我知道,如果有一個等值或替代?
代碼:
<?php
//haystack
$_POST['theaddress'] ='160x160/photo.jpg';
//return all after the needle '160x160/', inclusive
$varA = strstr($_POST['theaddress'], '160x160/');
//build new URL
$varA = "https://fbcdn-sphotos-g-a.akamaihd.net/hphotos-ak-ash3/t1.0-9"."$varA";
header("Location: $varA");
?>
你爲什麼不使用'的indexOf()'? – 2014-11-06 14:46:52
https://developer.mozilla.org/en-US/docs/Web/ JavaScript/Reference/Global_Objects/String/indexOf – 2014-11-06 14:47:16
谷歌顯示你的第一個結果是indexOf ...你只需要鍵入「javascript strstr」... – oopbase 2014-11-06 14:47:54