Php 去掉一个数字,每次减去最后一个数字后返回
假设我有一个号码1234567890,我想做一些循环,在MySQL查询中创建一些可用的东西 例如: 编号为Php 去掉一个数字,每次减去最后一个数字后返回,php,mysql,Php,Mysql,假设我有一个号码1234567890,我想做一些循环,在MySQL查询中创建一些可用的东西 例如: 编号为1234567890 查询中的可用部分应如下所示: SELECT * FROM table WHERE column IN (1234567890, 123456789, 12345678, 1234567, 123456, 12345, 1234, 123, 12, 1) 在这件事上伤了我的头,所以我希望有人能帮助我 非常感谢您……这是您想要的吗 where '1234567890' l
1234567890
查询中的可用部分应如下所示:
SELECT * FROM table WHERE column IN (1234567890, 123456789, 12345678, 1234567, 123456, 12345, 1234, 123, 12, 1)
在这件事上伤了我的头,所以我希望有人能帮助我
非常感谢您……这是您想要的吗
where '1234567890' like concat(column, '%') and length(column) > 0
这是你想要的吗
where '1234567890' like concat(column, '%') and length(column) > 0
您可以使用
substr
使用循环不断剥离数字的最后一个字符。如果以整数开头,则需要将其输入到字符串中才能工作
$x=1234567;
$x=(string)$x;
for($i=0; $i<strlen($x); $i++){
//Write SQL here or store them in an array, print...etc.
echo substr($x, 0,strlen($x)-$i);
}
$x=1234567;
$x=(字符串)$x;
对于($i=0;$i您可以使用substr
使用循环不断剥离数字的最后一个字符。如果您以整数开头,则需要将其键入一个字符串中,以使其正常工作
$x=1234567;
$x=(string)$x;
for($i=0; $i<strlen($x); $i++){
//Write SQL here or store them in an array, print...etc.
echo substr($x, 0,strlen($x)-$i);
}
$x=1234567;
$x=(字符串)$x;
对于($i=0;$i欢迎来到Stack Overflow!这个问题的信息有点少。您能分享您尝试过的内容和遇到的问题吗?欢迎来到Stack Overflow!这个问题的信息有点少。您能分享您尝试过的内容和遇到的问题吗?@spencer7593…谢谢。@spencer7593。非常感谢。