I currently have bbcode like this I’d like to use php’s preg_match so I can get the value of the image.jpg, regardless of what’s next to ‘caption=’. …
Tag: php
php adodb MSSQL connection
I have a linux server that I’m trying to use php adodb to connect to a MSSQL server. I’ve install mssql through yum etc and I know the server can connect to it as I’ve tried the following: Any ideas why my adodb wont connect, or any examples on how I can connect would be much appreciated. An…
How can i pass a single additional argument to array_map callback in PHP?
How can i pass a single additional argument to array_map callback? In my example i’d like to pass $smsPattern (as a second argument, after current element in $featureNames) to the function array_map …
change the PHP path to MAMPs PHP
I’m running PHP with MAMP on OSX 10.5.8 So if I want to run a script from console I always need to write which is annoying. Is there a way to change the default path to php so that I can write and still uses MAMPs PHP version? Answer Create a file called .bash_profile on your home directory (if you
Select on empty table but still get column names
I want to do a SELECT on an empty table, but i still want to get a single record back with all the column names. I know there are other ways to get the column names from a table, but i want to know if it’s possible with some sort of SELECT query. I know this one works when i
How to change the path to php.ini in PHP CLI version
The php that run on the webserver and the CLI version is not using the same php.ini file. If I do a command php –ini, it show this while my web version uses the php.ini in C:wampbinapacheApache2.2.21binphp.ini. This is probably very common for people using wamp. How do I change the Loaded Configuration …
Convert PHP date into javascript date format
I have a PHP script that outputs an array of data. This is then transformed into JSON using the json_encode() function. My issue is I have a date within my array and it’s not in the correct JavaScript format. How can I convert this within PHP so it is? Instead of the above for the date I need the equiva…
Wrap first word in tag with preg_replace — can’t reference fullstring match
I generated the following regex code with http://gskinner.com/RegExr/ where it works, but when I execute it with PHP, it fails to use the match in the replacement string. Output: Expected: I know that obviously the $& is not doing the correct thing, but how can I get it to work? Answer Try with this inste…
Generate array of random unique numbers in PHP
I’m trying to generate an array of random numbers from 0-n then shuffle (but ensure that the keys and values DO NOT match). For example: Note that both keys and values are from 0-4 but none of the keys and values are the same. Any thoughts? Answer
Getting start and end date of a PHP DatePeriod object?
How can i get the start and end date of a DatePeriod object? Answer DatePeriod only implements the Traversable interface and has no other methods to either access elements or retrieve them. You can do something easy to get start/end dates: