php 不用第三个变量 交换两个变量的值汇总
2024-10-20 18:56:36
//方法一:
$a ="abc";
$b="def";
$a = $a^$b;
$b = $b^$a;
$a = $a^$b;
//方法二:
list($a, $b)= array($b, $a);
//方法三:
$a = $a . $b;
$b = strlen( $b );
$b = substr( $a,0,(strlen($a)- $b ));
$a = substr( $a, strlen($b));
//方法四:(这个就比较有限制,必须用一个两个字符串都都不能出现的字符做为分隔符)
$a = $b.','.$a ;
$a = explode(',', $a);
$b = $a[1];
$a = $a[0];
//方法五:(这个是当两个数都是数字的时候)
$a = $a + $b;
$b = $a - $b;
$a = $a - $b;
有关注的可以加微信共同讨论一下!
最新文章
- 戏说HTML5
- Zookeeper:通过yarn实现大型分布式管理系统
- $.each与$().each
- RabbitMQ 入门
- Atitit. Xss 漏洞的原理and应用xss木马
- Windows远程桌面连接Ubuntu 14.04
- IEnumerator/IEnumerable接口
- Servlet个人总结
- Redmine配置
- 【转】ubuntu14.04 trusty的源
- Windows Phone开发(7):当好总舵主
- BZOJ4503 两个串 多项式 FFT
- 《python语言程序设计》_第三章(数字函数、字符串和对象)
- npm 更新版本
- ASP.NET MVC4在部署IIS后,运行时显示的是整个Web的目录列表
- Codeforces Round #437 B. Save the problem!
- excel技巧--一键求和
- [Error] 'exit' was not declared in this scope的解决方法
- php静态变量与方法与phar的使用
- js数组遍历some、foreach、map、filter、every、lastIndexOf、indexOf对比
热门文章
- 正确处理类的复合关系------新标准c++程序设计
- 进阶Kotlin-常见关键字
- luoguP3835 [模板]可持久化平衡树
- HttpClient 基于连接池的使用
- VS2019和net core 3.0(整理不全,但是孰能生巧)
- OpenStack-Mitaka
- [转][Unity3D]引擎崩溃、异常、警告、BUG与提示总结及解决方法
- 3.mouseenter和mouseover事件的区别
- bootstrap的使用2
- 【Leetcode】Maximum Product Subarray