duanliang789262 2016-11-19 14:05
浏览 25

检查文件夹中的所有图像并将第一个图像存储到阵列

public function set_array($set_value) {
  /*set empty class*/
  $tempclass = new stdClass();

  /*full Image path src*/
  $search_dir = "/domain/img/company/Image1-000000-016";

  /*open dir*/
  $images = glob("$search_dir/*.*");
  sort($images);

  /*loop thought dir and get first Image*/
  if (count($images) > 0) {
  /*get product imagepath and set as src*/
  $tempclass->src = $images[0];

  /*return all data to array*/
  $this->Imagedata[] = clone($tempclass);
  }

}

My intention was to check my folder image and store first image to Imagedata[], but I keep checking the Imagedata[] is empty, I don't know why. I checked the folderpath as well, it is correct so what did I do wrong?

  • 写回答

2条回答 默认 最新

  • dongmeng2687 2016-11-19 14:13
    关注

    maybe because you store your files in $files variable and then check for $images variable which is undefined?

    I really suggest you to spend some time into turning on E_NOTICE errors in your PHP environment, they help you a great deal in catching this kind of mistakes (it happens to everyone)

    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?