サポート » 使い方全般 » single.phpにエラーがでてしまい対処方法がわかりません。

  • 解決済 asx@

    (@asx-1)


    singel.phpで「Notice: Undefined offset: 0 in」というエラーが出てしまいなおせません。

    配列に値がセットされていないというエラーだということはわかったのですが、具体的にどう記述を修正したらよいのかわかりません。

    <?php
    function catch_that_image() {
    global $post, $posts;
    $first_img = ”;
    ob_start();
    ob_end_clean();
    $output = preg_match_all(‘/<img.+src=[\'”]([^\'”]+)[\'”].*>/i’, $post->post_content, $matches);
    $first_img = $matches [1] [0];

    if(empty($first_img)){ //Defines a default image
    $first_img = “http://xn--88jzc9b4e3iye.com/wp-content/uploads/2013/04/ep0.jpg&#8221;;
    }
    return $first_img;
    }
    ?>

    こちらの記述の$first_img = $matches [1] [0];の配列[0]のエラーだと思うのですが、記述をそう直したら良いのかわかりません。

    ご教授よろしくお願いいたします。

3件の返信を表示中 - 1 - 3件目 (全3件中)
3件の返信を表示中 - 1 - 3件目 (全3件中)
  • トピック「single.phpにエラーがでてしまい対処方法がわかりません。」には新たに返信することはできません。