ankur0101 Posted February 24, 2012 Share Posted February 24, 2012 Hi, I am performing some whois query using phpwois. http://www.phpwhois.org/ So after doing its object output i.e. $whois = new Whois(); $result = $whois->Lookup($domain); $winfo = ''; $utils = new utils; $winfo = $utils->showHTML($result); , I am getting following data for for phpfreaks.com> regrinfo->Array domain->Array name->phpfreaks.com nserver->Array ns1.serverpowered.net->204.13.168.4 ns2.serverpowered.net->216.12.222.4 ns3.serverpowered.net->66.97.171.74 ns4.serverpowered.net->66.97.171.254 status->Locked changed->2011-08-29 created->2001-10-11 expires->2016-10-11 registered->yes owner->Array name->Web Freaks address->Array 0->Contact Administrative () admin->Array email->domains@thewebfreaks.com name->Contact Administrative phone->4072751117 fax->+1.4072757706 address->Array 0->Web Freaks 4->3700 Commerce Blvd 5->Suite 154 6->Kissimmee, FL 34741 7->US tech->Array email->domains@thewebfreaks.com name->Contact Administrative phone->4072751117 fax->+1.4072757706 address->Array 0->Web Freaks 4->3700 Commerce Blvd 5->Suite 154 6->Kissimmee, FL 34741 7->US regyinfo->Array registrar->ENOM, INC. referrer->http://www.enom.com servers->Array 0->Array server->com.whois-servers.net args->domain =phpfreaks.com port->43 1->Array server->whois.enom.com args->phpfreaks.com port->43 type->domain Now I want to show Domain registrar (Enom, INC.) So I did following echo $winfo['regyinfo']; Now above code shows following >> registrar->ENOM, INC. referrer->http://www.enom.com servers->Array 0->Array server->com.whois-servers.net args->domain =phpfreaks.com port->43 1->Array server->whois.enom.com args->phpfreaks.com port->43 type->domain To obtain I mean to show ENOM, INC, I used following > echo $winfo['regyinfo']['registrar']; But it gave error, so I used following >> $temp = $winfo['regyinfo']; echo $temp['registrar']; But it give output as follows : < I dont know what wrong I am doing ? If it is showing regyinfo, then it should also show registrar. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/257699-simple-array-not-working-very-strange/ Share on other sites More sharing options...
batwimp Posted February 24, 2012 Share Posted February 24, 2012 I've never known an echo to display an array like that. Try using a var_dump($winfo) on your array instead of an echo and see if it outputs the array correctly. Post the output here for us all to see. Quote Link to comment https://forums.phpfreaks.com/topic/257699-simple-array-not-working-very-strange/#findComment-1320939 Share on other sites More sharing options...
ankur0101 Posted February 25, 2012 Author Share Posted February 25, 2012 Okay, I will try and update this thread. Quote Link to comment https://forums.phpfreaks.com/topic/257699-simple-array-not-working-very-strange/#findComment-1321041 Share on other sites More sharing options...
jamesxg1 Posted February 25, 2012 Share Posted February 25, 2012 It would be a great deal easier to read if you use print_r() to print it and then post back and I will take a look. echo '<pre>' . print_r($winfo['regyinfo']) . '</pre>'; James. Quote Link to comment https://forums.phpfreaks.com/topic/257699-simple-array-not-working-very-strange/#findComment-1321076 Share on other sites More sharing options...
ankur0101 Posted February 26, 2012 Author Share Posted February 26, 2012 var_dump($temp['registrar']) gave me following output : string(1)"<" Now using print_r($temp['registrar']) gives following output : < Quote Link to comment https://forums.phpfreaks.com/topic/257699-simple-array-not-working-very-strange/#findComment-1321401 Share on other sites More sharing options...
jcbones Posted February 26, 2012 Share Posted February 26, 2012 The only whois utils class I can find has utils::showHTML() returning a string. I'm betting that the utils class you have does the same, or outputs an object. If you could post the method utils::showHTML(), it would clear up a lot of questions. Quote Link to comment https://forums.phpfreaks.com/topic/257699-simple-array-not-working-very-strange/#findComment-1321403 Share on other sites More sharing options...
PFMaBiSmAd Posted February 26, 2012 Share Posted February 26, 2012 The showHTML method is for displaying the information. It is not an array of data that you access element of. When you do access a non-existent index of a string, it returns the first character of that string. To access elements of the result, AFAIK (I haven't figured out how to actually use that class based on its excellent documentation - edit: found something useful in the readme file) you would just refer to elements within $result. Edit: What does the following show - echo '<pre>',print_r($result, true),'</pre>'; Quote Link to comment https://forums.phpfreaks.com/topic/257699-simple-array-not-working-very-strange/#findComment-1321404 Share on other sites More sharing options...
PFMaBiSmAd Posted February 26, 2012 Share Posted February 26, 2012 Upon getting this to work, the answer to your first post in the thread is - echo $result['regyinfo']['registrar']; Quote Link to comment https://forums.phpfreaks.com/topic/257699-simple-array-not-working-very-strange/#findComment-1321408 Share on other sites More sharing options...
ankur0101 Posted February 26, 2012 Author Share Posted February 26, 2012 Upon getting this to work, the answer to your first post in the thread is - echo $result['regyinfo']['registrar']; Yeah, I was about to write this that using this, it works. Problem SOlved. Quote Link to comment https://forums.phpfreaks.com/topic/257699-simple-array-not-working-very-strange/#findComment-1321409 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.