我想做var_export()并去掉数组上的所有数值数组键.我的数组输出如下:
array (
2 =>
array (
1 =>
array (
'infor' => 'Radiation therapy & chemo subhead',
'PPOWithNotif' => '',
'PPOWithOutNotif' => 'Radiation therapy & chemo PPO amount',
'NonPPO' => 'Radiation therapy & chemo Non PPO amount',
),
),
3 =>
array (
1 =>
array (
'infor' => 'Allergy testing & treatment subhead',
'PPOWithNotif' => '',
'PPOWithOutNotif' => 'Allergy testing & treatment PPO amount',
'NonPPO' => 'Allergy testing & treatment Non PPO amount',
),
)
)
Run Code Online (Sandbox Code Playgroud)
通过这样做,我可以随机播放数组值而无需担心数值数组值.
我尝试过使用echo preg_replace("/[0-9]+ \=\>/i", '', var_export($data));但它没有做任何事情.有什么建议?我的正则表达式有什么我没做的吗?有没有更好的解决方案呢?
您必须设置var_exportto的第二个参数true,否则您的调用不会有返回值preg_replace。
参考: https: //php.net/manual/function.var-export.php
return
如果使用并设置为TRUE,var_export()将返回变量表示形式而不是输出它。
更新:回顾这个问题,我有一种预感,一个简单的array_values($input)就足够了。