PHP 警告:strpos() 期望参数 1 是字符串,数组给定


PHP Warning: strpos() expects parameter 1 to be string, array given

在这个问题中,我看到$handle = @fopen($thumb, 'r');在哪里更改为$handle = @file_get_contents($thumb);,因为他需要使用file_get_contents作为字符串。

我收到同样的错误,但我没有看到需要更改的 fopen(( 元素? 这需要在哪里发生?

} elseif( strpos($post_id, 'user_') !== false ) {
    $user_id = str_replace('user_', '', $post_id);
    $user_id = intval( $user_id );
    $v = get_user_meta( $user_id, $field['name'], false );
    // value is an array
    if( isset($v[0]) ) {
        $value = $v[0];
    }

从错误$post_id 是一个数组。strpos 的示例

$mystring = 'abc';
$findme   = 'a';
$pos = strpos($mystring, $findme);

在代码中查看包含值print_r($post_id)

 strpos($post_id, 'user_')//here $post_id is array

函数strpos()用于比较字符串,并且您已将数组作为第一个参数传递。

$post_id可能是一个数组。