jbonzey Posted November 26, 2012 Share Posted November 26, 2012 The application has to do with an alarm system. When an alarm event occurs it generates a 16 digit/character number and logs it on my linux server. I am trying to translate the code into english using str_replace. The problem i have is the last character/number is a checksum and changes so my search never comes up with a match. I got around this by just seaching the first 15 digits/characters even though the string is 16 digits/characters. This works and i have a valid match. Problem is once the replace happens, the 16th digit/character is showing up to the right of the replace. Question /Example 1: I can only search on the first 15 characters/digits of the 16 generated by the alarm The alarm generates the following string: 769418113401001A I execute the following line: file_put_contents($file,str_replace('769418113401001','769418113401001 Garage Kitchen Entry ',file_get_contents($file))); The output from the above line is: 769418113401001 Garage Kitchen Entry A How do I stop the 16th character/digit in this case "A" from showing up in the output????????????? Question/Example 2: I can only search on the first 10 characters/digits of the 16 generated by the alarm The alarm generates the following string: 7694181250123456 I execute the following line: file_put_contents($file,str_replace('7694181250','7694181250 Fire Alarm ',file_get_contents($file))); 7694181250 Fire Alarm 123456 How do i stop the last 6 digits/characters from showing up in the output? thanks for your help !!!!!!! Quote Link to comment Share on other sites More sharing options...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.