kennethamby Posted March 5, 2014 Share Posted March 5, 2014 Hello, First of: I have not been working with PHP for 5 years, and suddently decided: But I miss it. So startet working on a new site, where some of the code has allreade been done, but i do not work like he would like it to. So I am taking over, and my first real problem is this:I have this value:<?php echo gethostbyname($server_data['ip']) . ":" . $server_data['port']; ?>And it works fine. But! (and not in the ass kind of way) There are a port i dont need it to show. So i need to modifide it so if the port number is 1234 its no shown at all. I was thinking something like this: <?php echo gethostbyname($server_data['ip']) . ":" . $server_data['port'] if 'port' = 1234 return null; ?> The above do not work (and im sure its my fault, but i cannot find the right way to do this)! Help ? Regards, Kenneth Quote Link to comment Share on other sites More sharing options...
jairathnem Posted March 5, 2014 Share Posted March 5, 2014 if($server_data['port'] != 1234){ echo gethostbyname($server_data['ip']) . ":" . $server_data['port']; } else return null; Quote Link to comment Share on other sites More sharing options...
kennethamby Posted March 5, 2014 Author Share Posted March 5, 2014 I cant test that for the next hour, but will that not return the total of 'null' (meaning: will that code not remove both the IP and the Port?) atm is shows: serverIP and serverPort. (ex: 1.2.3.4:1000) and that is OK. but only one port should not be displayed. (the 1234 port) So if a server has the adresse: 1.2.3.4:1000 it shoud display the ip and the port. But if a server has the adresse: 1.2.3.4:1234 it shoud only display the ip and not the port again: I cant test the script for the next hour, but thank you so mutch for your help! Regards Kenneth Quote Link to comment Share on other sites More sharing options...
Solution Barand Posted March 5, 2014 Solution Share Posted March 5, 2014 echo gethostbyname($server_data['ip']); if($server_data['port'] != 1234){ echo ":" . $server_data['port']; } Quote Link to comment Share on other sites More sharing options...
kennethamby Posted March 5, 2014 Author Share Posted March 5, 2014 echo gethostbyname($server_data['ip']); if($server_data['port'] != 1234){ echo ":" . $server_data['port']; } Thank you ! That seems to work perfectly ! Quote Link to comment 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.