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条)

报告相同问题?

悬赏问题

  • ¥50 hyper默认的default switch
  • ¥15 网站打不开,提示502 Bad Gateway
  • ¥20 基于MATLAB的绝热压缩空气储能系统代码咨询
  • ¥15 R语言建立随机森林模型出现的问题
  • ¥20 unity内置语言切换的按钮设置
  • ¥15 中级微观经济学,生产可能性边界问题
  • ¥15 TCP传输时不同网卡传输用时差异过大
  • ¥15 请各位看看我写的属于什么算法,或者有更正确的写法?
  • ¥15 html5 qrcode 扫描器
  • ¥15 爬取网页信息并保存需要完整代码