dtzhfb4869 2017-07-06 12:34
浏览 142

如何从多个php数组中获取特定索引值并存储在数组中

I've multiple arrays received from db table. now i'm trying to check "is their birth date == current date" if yes then their contact numbers saved in a array called birthdays

Here is my try

$curr_date = date('m/d');

$birthday = array(); // array initialization
$anniversary = array(); // array initialization

$con=mysqli_connect("localhost","root","","birthdays");


$sql="SELECT * FROM users";

$result=mysqli_query($con,$sql);

$row=mysqli_fetch_assoc($result);

echo "<pre>";

if ($result=mysqli_query($con,$sql))
{
    while ($row=mysqli_fetch_assoc($result))
    {
        print_r ($row);
    }
}

Here is a image of current code with expected description

enter image description here

I'm trying lot of time but unable to achieve exact result. kindly guide me. Thanks

  • 写回答

3条回答 默认 最新

  • dongyi9783 2017-07-06 12:44
    关注

    I think you need something like this?

    $date1 = date('m-d', strtotime($row['birth_date']));
    $date2 = date('m-d');
    
    if ($date1 == $date2)   {
        echo 'Happy birthday!';
    }
    

    See PHP date function for more info.

    评论

报告相同问题?

悬赏问题

  • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体
  • ¥88 实在没有想法,需要个思路
  • ¥15 MATLAB报错输入参数太多
  • ¥15 python中合并修改日期相同的CSV文件并按照修改日期的名字命名文件
  • ¥15 有赏,i卡绘世画不出
  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题
  • ¥15 COCOS的问题COCOS的问题
  • ¥15 FPGA-SRIO初始化失败