如何使用 PHP 从 mysql 读取值 [英] How can I read the value from mysql using PHP

查看:60
本文介绍了如何使用 PHP 从 mysql 读取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我在 mysql 中的一个字段中看到的一个值,用于 wordpress 数据库

Following is a value I am seeing in one of my fields in mysql for wordpress database

a:2:{i:0;i:31;i:1;i:23;}

这是什么格式?如何获得使用 PHP 的替代值?

What is this format? How can I get the valued of alternate I using PHP ?

推荐答案

那是一个 serialize()'d 变量,可以使用 unserialize() 转换回适当的数据类型 - 在这种情况下是一个带有整数索引和值的数组.

That is a serialize()'d variable, you can use unserialize() to convert back to the appropriate datatype - in this case an Array with Integer indexes and values.

对于 WordPress,有一个名为 maybe_unserialize() 的函数如果您不确定它是否已被序列化,则对数据库值很有用.

For WordPress there is a function called maybe_unserialize() which is useful for database values if you aren't sure if it has been serialized or not.

这篇关于如何使用 PHP 从 mysql 读取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆