Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About x1705

  • Rank
  1. That worked great.. Had to research on accessing the proper keys, etc. So I learned some more. Truly appreciated. Thanks. X.
  2. Thank you!! That looks like it will work.. Very much apprecited!! I will let you know. Cheers.
  3. I had to try and explain it to myself also, ..here is the simplest way i think i can, if it helps. -------------------------------------------------------------------------------------------------------------------------------------------- $a1="Bob Sally Joe"; $b2="sometext Bob1:2 here Joe1:1 more text Sally2:3 there." if ANY "word:number" Combo of $b2 matches a Word in $a1 then get each matching $b2 "word:number combo" into an array OR seperate strings. ie; would be something like this: $c1=Bob1:2 $c3=Joe1:1 $c4=Sally2:3 Then secondly, (or perhaps within the same Regex?) I need to Insert a '+' between each $c strings LAST alpha-character and BEFORE its First Number. ?Do I need to 'split' each $cX at the last alpha character add a '+' reassemble $c strings to end result in: $d1=Bob+1:2 $d3=Joe+1:1 $d4=Sally+2:3 or is there a better, complex 'regex' that can do all of this?
  4. Thanks for the reply. I believe i stated in the original post what 'result' i am after. (towards the bottom). I am Trying to get the NAME and NUMBERS to be correct. the last line of above post shows the results i am getting, since the NAME and number:number are in a different Array, the keys don't coincide with teh proper element. Notice "BOB" is ok (the KEY[0] from Array) but ROB and SUE's (numbers) are exchanged. Hope that helps clarify. Sorry it wasnt clear enough. Thanks. I have personally been trying to resolve this for a few days, i have as far as i know/to my knowledge tried all the variants (that I can understand) using array_sort, preg_match_all, array_intersect_key, to just name a few.. I am working on a Regex type solution now.. and splitting fuctions, etc now. Hope that is clearer. Thanks for your consideration.
  5. Hi, simply put; I am having a very difficult time trying to find a way I can Match (partial?) strings, comparing to 2 arrays (the matches have different [Keys].) for example: $abs="Bob Rob Sue"; $abt="sometext Bob1:2 moretext Sue3:4 othertext Rob5:6 etc"; how can I put into code, when "Bob1:2" is used, it finds a match of "Bob", and assigns the complete string of "Bob1:2" ? The course I have been trying I get Bob, Rob, and Sue.. but the #numbers# are in the wrong place. ie; it will result with "Sue5:6" I understand its a [key] issue, using array_intersect along with some explodes/implodes has helped get me this far.. but i am stumped. Someway of matching the two arrays coreectly (or keys) would be what i need to figure out. Heres is what i have now: Thank you for any help, at all. cheers. <?php $abs="Bob Rob Sue"; $abby="sometext Bob1:2 is Sue3:4 where Rob2:1 etc"; $nums = preg_replace('/[a-zA-Z]/', ' ', $abby); $lets = preg_replace('/[0-9]:?[^0-9]/', ' ', $abby); //$lets1=array_intersect($abs, $lets); $absArr = explode(' ', $abs); $abbyArr = explode(' ', $lets); $letsx=array_intersect($absArr, $abbyArr); //echo $letsx[0] . "</br>"; //############################################# $nums1='/(\d+\:\d+)/s'; preg_match_all($nums1, $nums, $nums2); foreach($nums2 as $numsx){ } $abi0="$letsx[0]+$numsx[0]"; $abi1="$letsx[1]+$numsx[1]"; $abi2="$letsx[2]+$numsx[2]"; $answer=$abi0."</br>".$abi1."</br>".$abi2."</br>"; echo $answer; ?> current results: Bob+1:2 Rob+3:4 Sue+2:1 My desire is that it would Result in: Bob+1:2 Sue+3:4 Rob+2:1 The #nums are obviously correct. but the #letters (words/names) obviously are not the same "[key]". I hope that this is doable.. Thanks in advance.
  6. Perfect, thanks for that.. (link) yes. I think that is a common issue, understanding.
  7. Sorry about the last request/post, i think it was my error, it does work.. just took some time to insert it correctly within the current php. I appreciate the help! and I noted Benanamen's TAGLine; Dually noted. lol That would be nice, but in my php unenlightened mind, It is hard to phrase the "problem", half or mostof the time.. i don't KNOW what the Problem is.. and when that is apparent, it is finding the "proper" way to explain something/ask in a way that i do not understand, hence.. the Question. But, i get what you are saying.. truly. I htink forming the proper Question is the hardest part for newbies. Thank you, i appreciate your help!
  8. if $mT Does_Not contain a matching word(s), I still need it to carry that value to the end. This is the way it is working, but only when it matches a word.
  9. Thanks for asking, I have a Bot for Facebook Messenger that i use, and in a group chat, say someone is talking and they use a "keyword" that the bot will then interject some information on that "keyword".. sounds simple, It is highly complex in all.. as that is not all that it does, but that is what i am working on right now. It is not the "high end/ai" type bot with buttons.. more like an old school "IRC" Scripted one.. with whistles. thats my opinion anyways. It is not for professional use at all. it is just a hobby of mine that i enjoy with some people that i know. I believe the code provided from here is working, i just have to implement it correctly into the large PHP script that the bot uses now.. just takes me some (or a lot) of 'fidgeting' so, in essence; it would look somehting like this: me: good morning bot: {shows a forecast, or time - for example} someone: hey, thanks.. bot: {smiles} kind of 'random', but i think you get the picture.
  10. Perfect, that works.. now is it possible to make just the string it finds, "words" into a seperate string itself? I am looking into imploding it back? I will do some more reading, but that is what i am looking for. I believe this is all i needed to do.. let me know if you have a better (for some reason) solution. thank you!! *tip sent btw.. Thank you.
  11. I've (or am trying now) to add something like this: After the "preg_match" line. thinking somehow it needs to 'loop' through the string.. any better suggestions much appreciated. foreach($words as $v) { if(stripos($mT, $v)) { //Found a word $answer=$v; break;
  12. Hi, and thanks for any help with this. I have this but of php i have been trying relentlessly to get working.. for over a month. <?php $abs="one two three four words"; $mT = "testing for matching words"; $words=explode(' ', $abs); //$sf=($words); if (preg_match($words, $mT)) { echo "the url $mT contains a Word"; } else { echo "the url $mT does Not contain a Word"; echo "$words[4]"; } ?> You see, I get a responce only using the last line "$words[4]", (obviously, because I am pointing it the Matching word, (ie: with [4]) What i need to have is that the script will automatically "find" that Matching Word for me with ANYwhere of the string of $abs (not just the beginning or the ending)". not making it confusing, but the obvious word in this I am looking to find is the word, "words". 😕 Thanks so much for any help.
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.