karimali831 Posted August 2, 2011 Share Posted August 2, 2011 Hey! I am sure there is a way round this... I am using one column to store both IP and port e.g. 123.45.67.89:1234 I want to fetch only the IP, so I want to the output before the double dot. Can someone show me how I can do this please? Many thanks... Quote Link to comment https://forums.phpfreaks.com/topic/243604-fetch-before-double-dot/ Share on other sites More sharing options...
Maq Posted August 2, 2011 Share Posted August 2, 2011 There are a bunch of different ways to do this, I prefer something like this: $s = "123.45.67.89:1234"; $pieces = explode(":", $s); echo "IP: " . $pieces[0]; echo "Port: " . $pieces[1]; Quote Link to comment https://forums.phpfreaks.com/topic/243604-fetch-before-double-dot/#findComment-1250754 Share on other sites More sharing options...
gristoi Posted August 2, 2011 Share Posted August 2, 2011 <?php $fullIp = '123.45.67.89:1234'; $justIp = explode(':',$fullIp); //this gives you an array created from the string so $justIp[0] is what you need ?> Quote Link to comment https://forums.phpfreaks.com/topic/243604-fetch-before-double-dot/#findComment-1250755 Share on other sites More sharing options...
karimali831 Posted August 2, 2011 Author Share Posted August 2, 2011 thank you! Quote Link to comment https://forums.phpfreaks.com/topic/243604-fetch-before-double-dot/#findComment-1250831 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.