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... 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]; 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 ?> 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! Link to comment https://forums.phpfreaks.com/topic/243604-fetch-before-double-dot/#findComment-1250831 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.