gansai Posted July 8, 2018 Share Posted July 8, 2018 How to retrieve database array values from the object 'name' in php array (size=21) 9 => object(stdClass)[1017] public 'id' => string '9' (length=1) public 'dept' => string '2' (length=1) public 'class' => string '1' (length=1) public 'section' => string '1' (length=1) public 'name' => string 'plant modeling software, Smart 3D is a full suite of complementary software' (length=75) 14 => object(stdClass)[1018] public 'id' => string '14' (length=2) public 'dept' => string '2' (length=1) public 'class' => string '1' (length=1) public 'section' => string '2' (length=1) public 'name' => string 'integrated solution for all materials and supply chain management.]' (length=59) 2 => object(stdClass)[1037] public 'id' => string '1' (length=1) public 'course' => string '2' (length=1) public 'dept' => string '2' (length=1) public 'class' => string '1' (length=1) public 'section' => string '2' (length=1) public 'name' => string 'stakeholders in the EPC supply chain]' (length=46) Quote Link to comment https://forums.phpfreaks.com/topic/307468-retrieve-database-dump-values/ Share on other sites More sharing options...
Barand Posted July 8, 2018 Share Posted July 8, 2018 Assumimng your array is $data foreach ($data as $obj) { echo $obj->name . '<br>'; } Quote Link to comment https://forums.phpfreaks.com/topic/307468-retrieve-database-dump-values/#findComment-1559433 Share on other sites More sharing options...
gansai Posted July 8, 2018 Author Share Posted July 8, 2018 I tried foreach, but I could get the result. I have a function which returns array values (as shown above). Tried: function triple_plus(id) { .............................. $result = array(); return var_dump($result); } triple_plus(id); Output: array (size=21) 9 => object(stdClass)[1017] public 'id' => string '9' (length=1) public 'dept' => string '2' (length=1) public 'class' => string '1' (length=1) public 'section' => string '1' (length=1) public 'name' => string 'plant modeling software, Smart 3D is a full suite of complementary software' (length=75) 14 => object(stdClass)[1018] public 'id' => string '14' (length=2) public 'dept' => string '2' (length=1) public 'class' => string '1' (length=1) public 'section' => string '2' (length=1) public 'name' => string 'integrated solution for all materials and supply chain management.]' (length=59) 2 => object(stdClass)[1037] public 'id' => string '1' (length=1) public 'course' => string '2' (length=1) public 'dept' => string '2' (length=1) public 'class' => string '1' (length=1) public 'section' => string '2' (length=1) public 'name' => string 'stakeholders in the EPC supply chain]' (length=46) From the output, I want only the name column Quote Link to comment https://forums.phpfreaks.com/topic/307468-retrieve-database-dump-values/#findComment-1559435 Share on other sites More sharing options...
chriscloyd Posted July 8, 2018 Share Posted July 8, 2018 <?php foreach($array as $column => $value){ echo $column; echo $value; } ?> did this on on my phone. I’m not 100% sure what you are trying to do Quote Link to comment https://forums.phpfreaks.com/topic/307468-retrieve-database-dump-values/#findComment-1559437 Share on other sites More sharing options...
ginerjm Posted July 8, 2018 Share Posted July 8, 2018 Me neither! Just what are "database array values" since dbs don't usually have arrays in them. Quote Link to comment https://forums.phpfreaks.com/topic/307468-retrieve-database-dump-values/#findComment-1559443 Share on other sites More sharing options...
gansai Posted July 9, 2018 Author Share Posted July 9, 2018 The array was not from the database. It was a function output, where it displays all array values. I want to convert these array values to string. I want to extract the id, section and name. Quote Link to comment https://forums.phpfreaks.com/topic/307468-retrieve-database-dump-values/#findComment-1559450 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.