shmideo Posted November 29, 2014 Share Posted November 29, 2014 Hi Using: echo $row['columnname']; How can I strip off data from the above echo? The column always begins with 'Local/' then 3 digits then other unwanted data, lke 'Local/567@context-0000461d;1'. It would be ideal to just display '567'. Link to comment https://forums.phpfreaks.com/topic/292790-how-to-trim-output-from-an-echo/ Share on other sites More sharing options...
Barand Posted November 29, 2014 Share Posted November 29, 2014 echo substr('Local/567@context-0000461d;1', 6, 3); //--> 567 Link to comment https://forums.phpfreaks.com/topic/292790-how-to-trim-output-from-an-echo/#findComment-1498024 Share on other sites More sharing options...
shmideo Posted November 29, 2014 Author Share Posted November 29, 2014 Thanks Barand, I should have mentioned that the 3 digits will always change but after that it will also change. Sorry I should have been clearer. Link to comment https://forums.phpfreaks.com/topic/292790-how-to-trim-output-from-an-echo/#findComment-1498025 Share on other sites More sharing options...
Ch0cu3r Posted November 29, 2014 Share Posted November 29, 2014 should have mentioned that the 3 digits will always change but after that it will also change. Barands code returns the 3 digits after local/ Are you now saying their could be more than 3 digits after Local/? Link to comment https://forums.phpfreaks.com/topic/292790-how-to-trim-output-from-an-echo/#findComment-1498029 Share on other sites More sharing options...
shmideo Posted November 29, 2014 Author Share Posted November 29, 2014 I managed to get it working. echo substr($row['columnname'], 6, 3); This just displays those 3 digits. Local/ is always there, the rest changes, so just wanted the 3 digits to show. Sorry for the confusion Link to comment https://forums.phpfreaks.com/topic/292790-how-to-trim-output-from-an-echo/#findComment-1498030 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.