CanMan2004 Posted December 11, 2006 Share Posted December 11, 2006 Hi allI have the value[code]$where = $rows['areaname'];[/code]If you print [code]$where[/code], this outputs a code, which is something like76568765-12322or98976528-43266I want to do the above but ignore the first 8 characters, so for the above, it would output-12322or-43266Can this be done easily, or shall I rebuild how this is added to the database?Any help would be greatthanks Ed Link to comment https://forums.phpfreaks.com/topic/30222-ignore-first-2-7-characters/ Share on other sites More sharing options...
JasonLewis Posted December 11, 2006 Share Posted December 11, 2006 you can use the explode function.[code=php:0]$where = $rows['areaname'];$split = explode("-", $where);echo "First 8: ".$split[0]."<br> Second 5: ".$split[1];[/code]there is some other ways as well. but i prefer using arrays. i love my arrays. :) Link to comment https://forums.phpfreaks.com/topic/30222-ignore-first-2-7-characters/#findComment-138923 Share on other sites More sharing options...
kenrbnsn Posted December 11, 2006 Share Posted December 11, 2006 There are many ways to do this, the easiest uses the function [url=http://www.php.net/substr]substr()[/url][code]<?php$str = '76568765-12322';echo substr($str,8);?>[/code]To ProjectFear: Your method doesn't produce the output the OP requested.Ken Link to comment https://forums.phpfreaks.com/topic/30222-ignore-first-2-7-characters/#findComment-138925 Share on other sites More sharing options...
CanMan2004 Posted December 11, 2006 Author Share Posted December 11, 2006 thanks Link to comment https://forums.phpfreaks.com/topic/30222-ignore-first-2-7-characters/#findComment-138970 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.