我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

PHP preg_grep变量

Using preg_grep, how would you search for an exact match of a variable? I was able to get the following code to return anything containing those letters, but can't seem to get only exact match.

$o is an array $a for example would be "at"

$c=preg_grep("/$a/",$o);
echo implode($c, ' ');

And the output would be something like: at cat hat mat

Using logic from bash grep I thought I could use ^\$a$ but apparently isn't correct. Any ideas?

近期文章

  • Wordpress:如何通过meta_value以desc顺序从wp_posts和wp_postmeta获取记录?
  • 在javascript中使用php
  • 会话用户数据出错
  • Php日期问题
  • Symfony方法返回null
  • 登录表单验证问题
  • 从集中列表中选择选项
  • 传递文本字段变量
  • Yii2外部数据检索困难
  • 使用AJAX和PHP下载CSV的问题
  • PHP中的Crontab文件系统错误处理
  • PHP:返回Laravel 4中更新行的ID
  • 将所有Redis数据导出到Laravel中的json OR txt文件中
  • PHP正则表达式始终为false [重复]
  • 从上周选择行进行计数
  • 使用“编辑”按钮编辑/更新mysql表
  • 垃圾邮件CakePHP电子邮件以及如何检查邮件是由用户阅读
  • 在会话期间将模型实例存储为服务
  • 我的Wordpress网站在上传jpg文件中创建像素化问题?
  • PHP exec()就像在错误的环境中一样运行

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华