-
1. Re: PHP show if wildcard
Ben Pleysier Jul 10, 2014 7:55 AM (in response to matthew stuart)The best way is to ensure that entries are uniformly, i.e. either all with or all without the http://
Where this is not possible, you can always add/remove http:// to/from the data by testing the first 7 characters for the existence of http://. This can best be done by using similar to
if (substr($url, 0, 7) == 'http://')
-
2. Re: PHP show if wildcard
matthew stuart Jul 10, 2014 11:04 AM (in response to Ben Pleysier)That's brilliant Ben, it's working just as expected, however since initially posting I have thought I might need to contend with https:// as well.
So, I have been trying to do this, but it's throwing a wobbler!
<?php if (substr($row_rs_maplistrow['fld_dURL'], 0, 7) == 'http://') or (substr($row_rs_maplistrow['fld_dURL'], 0, 8) == 'https://') { ?>
How do I apply an OR clause to this?
-
-
4. Re: PHP show if wildcard
matthew stuart Jul 10, 2014 11:38 AM (in response to Ben Pleysier)Yeah, I tried that too; it's throwing this error:
Parse error: syntax error, unexpected T_BOOLEAN_OR in /xxxxxxxxxxxx.php on line 502
I must've set something else wrong in the original code other than the ||
I've also tried this:
<?php if (substr($row_rs_maplistrow['fld_dURL'], 0, 7 == 'http://' || $row_rs_maplistrow['fld_dURL'], 0, 8 == 'https://')) { ?>
It prints the page, but gives this error in the section of the page it's meant to display:
Warning: substr() expects at most 3 parameters, 5 given in blah blah page on line 502
Any further thoughts?
-
-
6. Re: PHP show if wildcard
matthew stuart Jul 10, 2014 12:22 PM (in response to osgood_)Cheers osgood, that was almost there, but it helped me realise that I had a few too many brackets and in the wrong place. This is what ended up working for me:
if (substr($row_rs_recordset['fld_dURL'], 0, 7) == 'http://' || substr($row_rs_recordset['fld_dURL'], 0, 8) == 'https://')
However, after all of this help you chaps have given me, and thank you for it, I've just realised that if I do this:
if (substr($row_rs_maplistrow['fld_dURL'], 0, 4) == 'http')
http:// and https:// are covered in one fell swoop!
Thank you all the same though.



