webent Posted June 24, 2008 Share Posted June 24, 2008 I don't know if I'm going brain dead or what, but I cannot seem to be able to extract the data I want from this array... Please Help... Here's the query... $result = listaccts($host,$user,$accesshash,0); Here's a sample of the array output... Array ( [somedoma] => Array ( [0] => somedomain.com [1] => My Own Domains [2] => root ) [anotherd] => Array ( [0] => anotherdomain.com [1] => My Own Domains [2] => root ) [yetanoth] => Array ( [0] => yetanotherdomain.com [1] => My Own Domains [2] => root ) [lastdoma] => Array ( [0] => lastdomain.com [1] => My Own Domains [2] => root ) [] => Array ( [0] => ) ) What I need to do is pull the owners (somedoma, anotherd, yetanoth, lastdoma) Anyone have any idea how to do that? Link to comment https://forums.phpfreaks.com/topic/111601-help-with-array/ Share on other sites More sharing options...
kenrbnsn Posted June 24, 2008 Share Posted June 24, 2008 Try: <?php foreach ($result as $owner => dmy) if ($owner != '') echo $owner . '<br>'; ?> Ken Link to comment https://forums.phpfreaks.com/topic/111601-help-with-array/#findComment-572844 Share on other sites More sharing options...
webent Posted June 24, 2008 Author Share Posted June 24, 2008 Thank the heavens, I did so many variations of that until I was blue in the face... Thank You Very Much! Could I ask one more tiny question... If I wanted to match a variable against one of those array values, how would I go about such a task? i.e., a $_POST['username'], so that when a person enters a username, it checks against that $owner array? $result = listaccts($host,$user,$accesshash,0); foreach ($result as $owner => $dmy) if ($owner != '') echo $owner . '<br>'; My way would be to enter them into the database and then check against it, but that seems such a waste... Link to comment https://forums.phpfreaks.com/topic/111601-help-with-array/#findComment-572850 Share on other sites More sharing options...
webent Posted June 24, 2008 Author Share Posted June 24, 2008 I think this may work, I'll let you know... $result = listaccts($host,$user,$accesshash,0); $count = 0; foreach ($result as $owner => $dmy) { if ($owner == '$_POST[username]') { $count++; echo $owner . '<br>'; } } if ($count > 0) { $duplicate = 1; } Link to comment https://forums.phpfreaks.com/topic/111601-help-with-array/#findComment-572871 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.