config.php$_LANG['new_arrival'] = 'New Arrivals';$_LANG['hot_products'] = 'Hot Products';$_LANG['group_deals'] = 'Group Deals';$_LANG['specials'] = "Specials";$_LANG['after'] = '<div>Contact cu'stomer</div> <table><tr><td>service for</td></tr> <tr><td>order status and</td></tr> <tr><td>other after-sales issues</td></tr></table>'; $_LANG['group_deals'] = 'Group Deals'; $subject = file_get_contents("config.php");$pattern = '这里正则要如何写呢'; preg_match_all($pattern, $subject, $matches); print_r($matches);我要取出等号后面的所有内容,正则要怎样写呢? 请注意等号后面字符串中的符号(单引号,双引号,转义符己及换行都要取到)。结果如下:1. 'New Arrivals' 2. 'Hot Products' 3. 'Group Deals'4. "Specials"5. '<div>Contact cu'stomer</div> <table><tr><td>service for</td></tr> <tr><td>order status and</td></tr> <tr><td>other after-sales issues</td></tr></table>'想不通,你那都是个数组了可以直接通过键名来取干嘛还用正则!还有你干嘛要通过file_get_contents来取config.php中的数据?你完全可以把那个数组返回然后直接通过数组来操作还方便些
$subject =<<< 'TXT'$_LANG['new_arrival'] = 'New Arrivals';$_LANG['hot_products'] = 'Hot Products';$_LANG['group_deals'] = 'Group Deals';$_LANG['specials'] = "Specials";$_LANG['after'] = '<div>Contact cu'stomer</div> <table><tr><td>service for</td></tr> <tr><td>order status and</td></tr> <tr><td>other after-sales issues</td></tr></table>'; $_LANG['group_deals'] = 'Group Deals';TXT;$pattern = '/.*=s*(.+);/sU'; preg_match_all($pattern, $subject, $matches); print_r($matches[1]);
| service for |
| order status and |
| other after-sales issues |
技术高手,CSDN还是蛮多的。
config.php 一般 include 进来读数组取值就行
=s([''""A-Za-z1-9s/\-]*)
=s*([''""A-Za-z1-9s/\-]*)
config.php 一般 include 进来读数组取值就行
嗯。数组是可以直接用。但不是我的问题所在哈。
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号