ballouta Posted June 18, 2008 Share Posted June 18, 2008 Hello I have the following variable that contains a message text (body): $Email_Comments I want to the search in this text ($Email_Comments) for the words : "processed successfully" Please help thanks Link to comment https://forums.phpfreaks.com/topic/110711-solved-searching-a-string/ Share on other sites More sharing options...
Orio Posted June 18, 2008 Share Posted June 18, 2008 Do you want to know if this variable contains that certain substring? Do you want to know where? Do you want the text around it? I assume you only need to check whether $email_comments contains "processed successfully". This is done (in the most simple way) like that: <?php $email_comments = "...text...processed successfully...text..."; if(strpos($email_cmments, "processed successfully") !== FALSE) echo "It was processed successfully"; else echo "It wasn't processed successfully"; ?> Orio. Link to comment https://forums.phpfreaks.com/topic/110711-solved-searching-a-string/#findComment-568083 Share on other sites More sharing options...
ballouta Posted June 20, 2008 Author Share Posted June 20, 2008 Hi this is the code $email_comments = "Dear Customer, Thank you for placing an order for RPL file. Your order was processed successfully. Please find the zip file attached to this mail which contains both original Nokia and NSS files."; if(strpos($email_cmments, "processed successfully") !== FALSE) echo "It was processed successfully"; else echo "It wasn't processed successfully"; The output is :It wasn't processed successfully I also tried to add a point to the "processed successfully." but the same. why? Link to comment https://forums.phpfreaks.com/topic/110711-solved-searching-a-string/#findComment-570635 Share on other sites More sharing options...
Stephen Posted June 21, 2008 Share Posted June 21, 2008 Orio accidentily mis-spelled "comments" xD $email_comments = "Dear Customer, Thank you for placing an order for RPL file. Your order was processed successfully. Please find the zip file attached to this mail which contains both original Nokia and NSS files."; if(strpos($email_comments, "processed successfully") !== FALSE) echo "It was processed successfully"; else echo "It wasn't processed successfully"; Try that. Link to comment https://forums.phpfreaks.com/topic/110711-solved-searching-a-string/#findComment-570700 Share on other sites More sharing options...
Wolphie Posted June 21, 2008 Share Posted June 21, 2008 Orio accidentily mis-spelled "comments" xD Haha. (Sorry it was necessary ) Link to comment https://forums.phpfreaks.com/topic/110711-solved-searching-a-string/#findComment-570720 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.