dongya3627 2017-10-28 09:42
浏览 59
已采纳

PHP str_replace替换两个单词

My code is below..

echo $type = str_replace(array('q','h','f'),array('Quarter','Half','Full'),$_POST['type']);

here on the above line $_POST['type'] have These 3 values;

  1. $_POST type = 'q'
  2. $_POST type = 'h'
  3. $_POST type = 'f'

I want to replace

  • q with Quarter
  • h with Half
  • f with Full.

My Problem is when $_POST['type']='h',

The result of above code means value of $type came HalFull.

Why this is happening...

Is there any solution for this...?

Thanks

  • 写回答

3条回答

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 实值特征权重向量和特征选择,多分类
      • ¥15 INVEST年产水量模块结果出处理
      • ¥15 Neo4j 不显示关系
      • ¥15 这段代码有什么bug
      • ¥15 pip默认安装位置修改不成功
      • ¥15 C++ inline、staitc、const三合一谁能讲通透
      • ¥15 关于pyqt5中QThread的问题
      • ¥20 STM32基于HAL库使用串口发送16进制数组
      • ¥15 OpenCV报错 You can enable it via 'OPENCV_IO_ENABLE_OPENEXR'
      • ¥15 AT89C51的程序问题