IP.Nexus puts custom fields into a table all muddled up into one row and some how pulls the correct data out.
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
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);
.
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.
Since this looks as JSon, you can use a PHP JSon module to parse each row from MySQL.
<?php
(...)
while (...) {
$obj = json_decode($row);
// do something with $obj
}
The data in the database is in serialized(json) form.You can turn it into simple array using unserialize
. For example;if $mystr
is your string write
$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