我有一些代码,我正在从ASP转换为PHP,我遇到了
原音乐器所以我查找了str当量的php等价物。我测试了两者,当我测试时
strpos("E-","E")
我收到了 1 的结果,但是$imagesDir = '../gender/male/';
$imagesDir2 = '../uploads/';
$images = glob($imagesDir . '*.{jpg,jpeg,png,gif}', GLOB_BRACE);
$randomImage = $images[array_rand($images)];
$profile_picture = $randomImage;
我得到 0 的结果我被困在如何得到类似的在PHP中的InStr的结果
答案 0 :(得分:0)
您可以制作这样的InStr函数:
function InStr($haystack, $needle, $offset = 0)
{
$position = strpos($haystack, $needle, $offset);
return ($position !== false) ? $position += 1 : 0;
}