drbvm26000
2016-02-16 12:22
浏览 467
已采纳

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

In this question, I see where the $handle = @fopen($thumb, 'r'); was changed to $handle = @file_get_contents($thumb); because he needed to use file_get_contents for a string.

I am getting the same error but I do not see a fopen() element that needs to be changed? Where does this need to occur?

} 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];

    }

图片转代码服务由CSDN问答提供 功能建议

在此问题,我看到 $ 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 是一个数组
 if(isset($ v [0])){
 
 $ value = $ v [0]; 
 
} 
   
 
  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dtzk85937 2016-02-16 12:27
    已采纳

    From the error $post_id is an array. An example of strpos

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

    In your code print_r($post_id) to see containing values

     strpos($post_id, 'user_')//here $post_id is array
    
    评论
    解决 无用
    打赏 举报
  • 查看更多回答(1条)

相关推荐 更多相似问题