Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #16813

Re: how extract key and valu from object

From alex <alex@nomailno.it>
Newsgroups comp.lang.php
Subject Re: how extract key and valu from object
Date 2016-07-02 11:30 +0200
Organization Aioe.org NNTP Server
Message-ID <nl81k9$cip$1@gioia.aioe.org> (permalink)
References <nl5alr$g20$1@gioia.aioe.org> <87h9c98n2f.fsf@bsb.me.uk>

Show all headers | View raw


thanks for you suggestion I must see with calm

I find this solution also if isn't short
seen that
  print_r ($op_select);
I have this structure
Array (
[all] => Select
    [0] => stdClass Object ([option] => Array ([29] => A))
    [1] => stdClass Object ([option] => Array ([28] => B ))
    [2] => stdClass Object ([option] => Array ([31] => C ))
)



I solved so
$new = array();
  $i=0;
foreach ($op_select as $key) {
$i++;
if ($i==1)
{
   $new['all'] = $key ;
}
else
{foreach ( $key->option as $key1 => $val1)
              {echo $key1.' '.$val1.'<br/>';
               $newArr[ $key1 ] = $val1;}

}
}

only for first key
I set manually the key All and assign value Select by $key
this is a cicle also if inner variable I have only on element

after I take key and value by
Array ([29] => A)
Array ([28] => B
Array ([31] => C
with foreach ( $key->option as $key1 => $val1)
but think this isn't the better solution
but work;

Back to comp.lang.php | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

how extract key and valu from object alex <alex@nomailno.it> - 2016-07-01 10:46 +0200
  Re: how extract key and valu from object Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-07-01 15:12 +0100
    Re: how extract key and valu from object alex <alex@nomailno.it> - 2016-07-02 11:30 +0200

csiph-web