Array ( [data] => Array ( [0] => Array ( [ucsfeduworkingdepartmentname] => Array ( [0] => ITS ) [telephonenumber] => Array ( [0] => +1 415 502-7575 ) [ucsfeduprofilenodeid] => Array ( [0] => 39487740 ) [displayname] => Array ( [0] => Kevin Dale ) [postaladdress] => Array ( [0] => Box 0272 1855 Folsom Street, MCB Room 401S San Francisco, CA 94143 ) [uid] => Array ( [0] => 88834 ) [ucsfeduprimarydepartmentnumber] => Array ( [0] => 411112 ) [ucsfeduworkingtitle] => Array ( [0] => Sr Manager, Identity Mgmt ) [mobile] => Array ( [0] => +1 415 806-8480 ) [roomnumber] => Array ( [0] => 401S ) [mail] => Array ( [0] => kevin.dale@ucsf.edu ) [box] => Array ( [0] => Box 0272 ) [baseaddress] => Array ( [0] => 1855 Folsom Street San Francisco, CA 94143 ) [primary] => Array ( [box] => Array ( [0] => Box 0272 ) [building] => Array ( [0] => MCB ) [baseaddress] => Array ( [0] => 1855 Folsom Street San Francisco, CA 94143 ) [postaladdress] => Array ( [0] => Box 0272 1855 Folsom Street, MCB Room 401S San Francisco, CA 94143 ) [cn] => Array ( [0] => Campus ) [ucsfeduaddressprimaryflag] => Array ( [0] => true ) [roomnumber] => Array ( [0] => 401S ) [telephonenumber] => Array ( [0] => +1 415 502-7575 ) [ucsfedusecondarytelephonenumber] => Array ( [0] => ) [ucsfedutelephonenumberreleasecode] => Array ( [0] => ) [ucsfedusecondarytelephonenumberreleasecode] => Array ( [0] => ) ) [ucsfeduprimarydepartmentname] => Array ( [0] => F_IT Identity and Access Mgt ) [departmentname] => Array ( [0] => F_IT Identity and Access Mgt ) ) ) ) ----
raminshahab 0 Newbie Poster
Recommended Answers
Jump to PostFor the array posted you would do...
foreach($json_info as $key=>$value){ //use "\n" instead of "<br />" if printing in console echo $key."<br />"; //data /* each value is an array so need to use the index, otherwise it'll just print 'Array' */ foreach($value as $k=>$v) echo $k." …
Jump to Post@raminshahab, here is the array equivalent and you can try either one of the proposed solutions above. I know which one will work and which one will not. Your job now to test each.
$json_info = array('data'=> array( 'ucsfeduworkingdepartmentname'=>array('ITS'), 'telephonenumber'=>array('+1 415 502-7575'), 'ucsfeduprofilenodeid' => Array ('39487740' ), …
Jump to Postmatrixdevuk - yeah it 'would' work if the inner array didn't have arrays for values... as it stands your code would print 'Array' where $v occurs...and as far as syntax...print_r($k.':'.$v); ??
All 11 Replies
raminshahab 0 Newbie Poster
matrixdevuk 71 6t9.me Founder
jsuna 10 Newbie Poster
matrixdevuk 71 6t9.me Founder
veedeoo 474 Junior Poster Featured Poster
jsuna 10 Newbie Poster
matrixdevuk 71 6t9.me Founder
matrixdevuk 71 6t9.me Founder
raminshahab 0 Newbie Poster
matrixdevuk 71 6t9.me Founder
raminshahab 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.