yolop Posted December 18, 2008 Share Posted December 18, 2008 i want to find the number after string and put him in integer example i want to fint the numbers after width=" width="123" abcscddsfsdf the result need to be 123 and for width="346780"ccdscsdcdsc the result need to be 346780 how please?? thank. Link to comment https://forums.phpfreaks.com/topic/137587-need-to-search-in-string/ Share on other sites More sharing options...
rhodesa Posted December 18, 2008 Share Posted December 18, 2008 $string = 'width="123" abcscddsfsdf'; if(preg_match('/width="(\d+)"/',$string,$matches)) echo $matches[1]; Link to comment https://forums.phpfreaks.com/topic/137587-need-to-search-in-string/#findComment-719139 Share on other sites More sharing options...
yolop Posted December 18, 2008 Author Share Posted December 18, 2008 thankkkkkk Link to comment https://forums.phpfreaks.com/topic/137587-need-to-search-in-string/#findComment-719151 Share on other sites More sharing options...
yolop Posted December 18, 2008 Author Share Posted December 18, 2008 but if i want to find and replace that numbres how please??? Link to comment https://forums.phpfreaks.com/topic/137587-need-to-search-in-string/#findComment-719169 Share on other sites More sharing options...
akitchin Posted December 18, 2008 Share Posted December 18, 2008 but if i want to find and replace that numbres how please??? look into using preg_replace(). Link to comment https://forums.phpfreaks.com/topic/137587-need-to-search-in-string/#findComment-719170 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.