Braet Posted July 24, 2006 Share Posted July 24, 2006 4 hours later and I still can not find where I have gone wrong - nor can I find the answers on my own, so here goes.My script is not finding matches, the code (well.. in its current incarnation):[code]preg_match_all("/(.+?) \((.+?)\) \[(.+?)\]\: (.+?)/ims", $winremove, $match3);[/code]A typical line it will be searching:Jonathan (729) [Title]: Information, perhaps nothing - perhaps run on sentencesthe script will echo $winremove for me - actual echo:Array[];Array[];Array[];Array[];Jonathan (729) [Title]: Information, perhaps nothing - perhaps run on sentences.Arrayfrom this code:[code]echo <<<TESTMATCH $match3[1][$i];<BR> $match3[2][$i];<BR> $match3[3][$i];<BR> $match3[4][$i];<BR> $winremove<BR> $match3TESTMATCH;[/code]As I'm new to PHP (whoohoo, 5 days now!), I'm quite sure I'm falling under the ID10T ways and it's sitting plain as day in the coding above, but for the life of me I can not see it and hope someone here can.tia! Quote Link to comment Share on other sites More sharing options...
effigy Posted July 24, 2006 Share Posted July 24, 2006 The [tt]$match3[number][$i][/tt] format needs to be changed to [tt]{$match3[number][$i]}[/tt] -- see "Complex syntax" under [url=http://us2.php.net/manual/en/language.types.string.php]strings[/url]. Quote Link to comment Share on other sites More sharing options...
Braet Posted July 24, 2006 Author Share Posted July 24, 2006 ok, I see what you are stating for output - but in case that format was incorrect I also added the $match3 (no info is returning). What caused me to attempt printing out is that it was not putting the information (once separated) into the db table. I then set it to print each match, as well as the $winremove variable, and the $match array to see exactly where the issue was. Changing the echo coding still provides me with a lack of information in $match3 and the variables created from it.Perhaps I'm just missing something in the information you directed me to, but it seems to me the issue is that it is not finding any matches, there has no data to print (as $match3 should print as $winremove does, no?)tia! Quote Link to comment Share on other sites More sharing options...
effigy Posted July 24, 2006 Share Posted July 24, 2006 This works for me:[code]<?php $winremove = 'Jonathan (729) [Title]: Information, perhaps nothing - perhaps run on sentences'; preg_match_all("/(.+?) \((.+?)\) \[(.+?)\]\: (.+?)/ims", $winremove, $match3); echo '<pre>', print_r($match3, true), '</pre>';?>[/code] Quote Link to comment Share on other sites More sharing options...
Braet Posted July 24, 2006 Author Share Posted July 24, 2006 as it does for me, and if I add a little $ in there at the end, it gives me everything I need. I now officially feel sick that I spent 6 hours focused on the wrong issues - thanks so much, now I can move on to figuring out why it's not going into my db (found 2 other issues based on your info). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.