Jump to content

garyed

Members
  • Posts

    160
  • Joined

  • Last visited

Everything posted by garyed

  1. If I use either of these statements, the result is the same. Joe has ([\d.]+) large apples Joe has (\d.+) large apples It doesn't seem to matter whether I put the square brackets in or not. Are those brackets are there for a reason beyond the scope of the usage in this particular statement?
  2. I have been learning & experimenting with regular expressions as you suggested & was just curious as to why you use the square brackets inside the curly brackets. I've found that whether I use the square brackets or not, the result is the same. Is it optional or is there a specific reason why they should be used?
  3. My bad, I was trying to make my example simple to get across what I was trying to do & never even considered that the answer could be different if there were decimals involved. Hopefully I'll be a little more thorough next time, but I really appreciate the help from you guys here.
  4. Thank you, That was what I needed & I definitely do need to spend a lot more time learning those expressions. I know it's wrong but I usually learn backwards & try to find a solution to a problem when i run into one instead of learning the basics first.
  5. I appreciate your help but I don't think that solves the problem. I just need to find one specific unknown number in a specific string out of a huge string with multiple numbers. The example of "Joe has (x) large apples" would be the line I'm searching for in like 1,000 lines of code with multiple numbers where (x) is an unknown number. Mac_gyver's solution worked because it took the specific string where the unknown number was inside it & pulled it out. The only problem is that it would only pull out a whole number & the decimal part was lost. Your solution would come up with too many numbers that I would still have to find a way to narrow it down to the specific string that holds the correct number.
  6. Your solution would work if I knew the number in the string but the problem is that don't know the number that will be in the the string that I'm searching for. Basically I'm searching for the number inside a specific string that is inside a larger string.
  7. Well I thought everything was solved but i found that (\d+) only works on whole numbers. I didn't think it would matter if the number had a few decimal points but I was obviously wrong. If there is a decimal like 5.5 or 5.25 then it will only pick up the 5 & not the rest of the number.
  8. Thank you, that's what I was missing.
  9. I've tried preg_match, preg_match_all & preg_quote but I can't find the syntax where I can find an unknown value in the string. All the examples I've found assume there are no unknowns in the string. In my string "Joe has 5 large apples", the number 5 is unknown during the programming call & I only know the string is "Joe has * large apples" .
  10. I want to search for a string like: "Joe has 5 large apples" but don't know the actual number. In other words I want to search for the whatever number is in between "Joe has" & "large apples" I assume there is a way to do that in php but I haven't been able to find it. If so can someone help me with the solution ?
  11. Thanks, I've been reading up on the Apache site but I still haven't figured out how to enable mod_ssl. It explains a lot about it but I don't see the actual steps to add it to the config file.
  12. I'm using Apache on my home server & I ran the same code on my webhost server which I assume is Apache also. My phpinfo() shows Apache under server software environment on my webhost. Neither nginx or FPM show up anywhere in my phpinfo() on either servers. mod_php7 shows on my home server but not on my webhost's server. Home server running php 7.2.34, Web server running php 7.4.30
  13. I printed out the results of $_SERVER & there's nothing about SSL_PROTOCOL. The only thing close is a SERVER_PROTOCOL I also searched the results for "1.3" because I know that is the version of TLS that I'm running & it came up empty. I tried gw1500se's suggestion earlier & it didn't work so I thought he was just joking but maybe not.
  14. Thanks, that makes sense why it's not as simple as I thought it would be though I don't completely understand it. Since php is a server side language then I don't get why it doesn't have access to the same info that the server has. I must confess that I have no idea what nginx is, let alone how to pass a variable into the php environment from it.
  15. I've been trying to find the code or commands needed to find the users TLS version & everything seems to point to specific sites like: $ch = curl_init('https://www.howsmyssl.com/a/check'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $data = curl_exec($ch); curl_close($ch); $json = json_decode($data); echo "<h1>Your TLS version is: " . $json->tls_version . "</h1>\n"; Is it really that difficult to get a users TLS version without relying on another site to do it for you? I would have thought that there is a simple command like there is to get the users ip address but I guess not. Any enlightenment would be appreciated.
  16. It's a calculation program that defaults to about 50 inputs but if the user chooses, it can go up to 1,000 inputs.
  17. That seems like a great idea. I wish I had done that before building my site. I've can have as much as 1,000 variables on one page so it's going to be a lot of work no matter what I do now. Thanks again for the ideas
  18. I've tried these two options & they seem to work OK. The null option works better if I'm using the variable for any mathematical calculations. Is there anything wrong with declaring all variables that might be used in a form with the null fallback value as I did below? $var=$_POST['var']; ?? ''; $var=$_POST['var']; ?? null;
  19. "Now I see", says the blind man Thanks for the explanation. Now it looks like the only problem I'll have to be careful about is not having this type of universal fix to affect my sessions too.
  20. I really appreciate the ideas but I have to admit that I don't understand the examples. I have no idea what the : ?? 'Guest'; does or even means. I am actually learning as I'm going, sort of on an as needed basis. Things that may seem obvious to the experienced programmer, are not obvious to me. I'm going to do a little testing with some of this stuff & see if i can make it work.
  21. On pages where there are only a few variables I've tried : if (!isset($_POST['var1'])) { $var1=""; } else { $var1=$_POST['var1']; } That works but I don't want to have to do that with every variable.
  22. I have a lot form variables where I'm having the errors show up since I updated my php version on my webhost server. Since I have well over 100 variables, it's going to take a lot of time to correct them so i just disabled errors for now in the php.ini file to keep things working. I was wondering that since form variables are in kept an array, if there isn't an easy way to have them all initiated when the page loads. I think that would solve the majority of the errors & there wouldn't be that many left. Any ideas appreciated?
  23. Update, I decided to uninstall my LAMP server & reinstall it to see if that would fix anything & sure enough, it did. I'm not sure what happened to only effect two directories but they are working fine since I reinstalled Apache. Anyways, thanks for all the ideas.
×
×
  • 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.