[英]How to Extract Data from a field with multiple values?
IP.Nexus puts custom fields into a table all muddled up into one row and some how pulls the correct data out. IP.Nexus将自定义字段放到一个表中,所有表都混成一排,并介绍了如何提取正确的数据。
basically my custom fields row looks like so: 基本上我的自定义字段行看起来像这样:
a:2:{i:2;s:4:"Test";i:3;s:10:"Accounting";}
How do i select what item to pull as i would like to out put just one item not the whole row, is it with delimiters or string splitter, as i am novice with this part of mySQL 我该如何选择要拉的项目,因为我想只放一项而不是整行,是用定界符还是字符串分隔符,因为我是mySQL的新手
Cause i would like to echo out just the advertising on its own and also vice versa for the testing. 因为我只想回显广告,反之亦然。
Thanks in advance 提前致谢
It's a serialized array using serialize()
function so you can get its contents using unserialize($YourString);
这是一个使用
serialize()
函数的序列化数组,因此您可以使用unserialize($YourString);
获取其内容unserialize($YourString);
. 。
But I see that you string is corrupted for deserialization, because s:4:
in s:4:"advertising"
says that after s:4:
4 character long string is expected that advertising
is not. 但是,我看到你的字符串被破坏的反序列化,因为
s:4:
在s:4:"advertising"
说,经过s:4:
4个字符长的字符串,预计advertising
是没有的。
The data in the database is in serialized(json) form.You can turn it into simple array using unserialize
. 数据库中的数据采用序列化(json)格式。您可以使用
unserialize
将其转换为简单数组。 For example;if $mystr
is your string write 例如;如果
$mystr
是您的字符串,请输入
$mystring=unserialize($mystring)
You will get normal array of this string You can do 您将获得此字符串的普通数组,您可以执行
foreach($mystring as $str){
$ads[]=$str['advertising'];
}
and the resulting array $ads
will be the ads you like in simple array form 然后生成的数组
$ads
将是您喜欢的简单数组形式的广告
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.