Reputation: 59
I need to fetch the value of data "Studie". Below data is fetched through a custom table by wordpress query . How can i do it ?
Array ( [0] =>
stdClass Object ( [data] => a:8:{i:14;O:8:"stdClass":4:{s:5:"label";s:7:"Fornavn";s:5:"value";s:4:"test";s:4:"type";s:5:"Fname";s:4:"meta";N;}
i:15;O:8:"stdClass":4:{s:5:"label";s:9:"Etternavn";s:5:"value";s:3:"net";s:4:"type";s:5:"Lname";s:4:"meta";N;}
i:16;O:8:"stdClass":4:{s:5:"label";s:6:"Kjønn";s:5:"value";s:6:"Kvinne";s:4:"type";s:5:"Radio";s:4:"meta";N;}
i:17;O:8:"stdClass":4:{s:5:"label";s:6:"Studie";s:5:"value";s:8:"Juss UiB";s:4:"type";s:6:"Select";s:4:"meta";N;}
i:18;O:8:"stdClass":4:{s:5:"label";s:3:"År";s:5:"value";s:6:"1. År";s:4:"type";s:6:"Select";s:4:"meta";N;}
i:13;O:8:"stdClass":4:{s:5:"label";s:6:"E-post";s:5:"value";s:14:"[email protected]";s:4:"type";s:5:"Email";s:4:"meta";N;}
i:20;O:8:"stdClass":4:{s:5:"label";s:7:"Adresse";s:5:"value";s:11:"h jhgjklhjk";s:4:"type";s:7:"Textbox";s:4:"meta";N;}
i:21;O:8:"stdClass":4:{s:5:"label";s:2:"By";s:5:"value";s:3:"jhj";s:4:"type";s:7:"Textbox";s:4:"meta";N;}} ) )
Upvotes: 1
Views: 651
Reputation: 341
You are fetching data from wordpress table. To understand better, It need to be unserialize first
OBJECT - result will be output as a numerically indexed array of row objects.
OBJECT_K - result will be output as an associative array of row objects, using first column's values as keys (duplicates will be discarded).
ARRAY_A - result will be output as an numerically indexed array of associative arrays, using column names as keys.
ARRAY_N - result will be output as a numerically indexed array of numerically indexed arrays.
Form : https://codex.wordpress.org/Class_Reference/wpdb#SELECT_Generic_Results#SELECT_Generic_Results
If your $user be the variable that stored result from wordpress query.
$mydata = unserialize($user[0]->data);
print_r( $mydata);
Value of i
be the Id of each stdClass Object
, Your required variable Studie
is at i:17
[I wrote this line on the basis of your Array in question.]
Try this
echo $mydata[17]->value;
Thanks
Upvotes: 1