dougaoshang0237 2013-03-06 13:25
浏览 110
已采纳

在PHP中的两个变量的值之间进行替换

I was wondering if it could be possible to make a substitution between the values of two variables, in PHP.

I can explain it better:

<?php
    $a = "Cat";
    $b = "Dog";

    // The strange/non-existent function I am talking about //
    MakeSubstitution($a, $b);

    // After this (non-existent) function the values of the variables should be:
        // $a = "Dog"
        // $b = "Cat"
?>

So, does it exist? I made searches but I found no results. Thanks in advance.

  • 写回答

2条回答 默认 最新

  • dongzhuo3059 2013-03-06 13:27
    关注

    Try this :

    $a = "Cat";
    $b = "Dog";
    
    list($a,$b) = array($b,$a);
    
    echo $a;
    echo $b;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程