开发者

using strlen the end of a string

i need to strip away the $_GET['id'] value from the end of $k. example name=address158, 158 is the id.. so is there away to strlens 158 from 'address' by using $_GET['id'] as the reference?

foreach($_POST as $k=>$v){
        @$select.=" `".mysql_real_escape_string($k)."` = '".mysql_real_escape_string($v)."',";
}
$select = rtrim($select,',');
$select = "UPDATE load_test SET".$select." WHERE Id=开发者_运维技巧".$_GET['id'];
mysql_query($select);


Something like this, perhaps?

$k = substr($k, 0, -strlen($_GET['id']));

I'm assuming that the identifier is always at the end of the string.


Lots of approaches here, depending on how strict your input is.

If you want to split by the = character: You could use strpos to find the = character, or you could use explode to split key and value.

If you want to use the ID, then you could use strrpos on the ID.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜