dsdzvprlp51692469 2018-09-03 11:42
浏览 19
已采纳

从2个其他变量制作PHP变量

I'm starting a magazine which has 3 editions. UK, US, and European. Each will be published online at different times, therefore each has a different issue number.

So I want to create a way of selecting which issue goes with which edition, but I don't know how to join these 2 parts together. The code I'm using is:

<?php
$this_edition = "UK";
?>

<?php
$UK_issue = "1";
$US_issue = "3";
$EU_issue = "2";
?>

<?php
$this_issue = // The Issue Relating to This Edition
?>

What I want to do here is basically call the issue number ( 1/3/2 ) which relates to the $edition I'm udating, in this case, UK.

So essentially : $this_issue = $edition_issue

Does anyone know how I can do this?

  • 写回答

5条回答 默认 最新

  • dongxing2030 2018-09-03 11:51
    关注

    What you're trying to do is possible...

    $this_issue = ${$this_edition.'_issue'};
    

    But it's way better to use the solution suggested by pr1nc3.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵