I’m trying to figure out what I’m doing wrong with this validation rule because its saying this error. Validation rule: Error: Severity: Warning Message: preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash Answer First, you need to fix your pattern. Your pattern rig…
Tag: php
How to specify ordered variables in gettext .po files?
I have a multi-lingual site that uses Zend_Translate PHP arrays to handle the translations. It works fine, but I’m trying to convert to using gettext since that offers extra features. However, I haven’t yet discovered the gettext equivalent of a feature that I liked in PHP array translations: n$ p…
Add six months in php
I’m trying to get the month, six months out from the current date. I’ve tried using: date(‘d’, strtotime(‘+6 month’, time())); But it doesn’t seem to work, always returns 01. Is there a better way to do this? Thank you! Answer I find working with DateTime much easier …
XXX is not a valid entity or mapped super class // and config options
I just started to use Doctrine2 and I have an error when I want to persist an entity. Here is my error: ‘Class “Myappappentityuser” is not a valid entity or mapped super class.’ eAccelerator is not installed on my computer. My app (I don’t use Symfony) structure is like that: MyA…
How to use preg_match to match numbers between hyphens?
I need to validate strings like this: I need the penultimate number between hyphens, so in this case ’10’. These are other examples: Can you help me? Answer this RegExp should do the trick using a positive lookahead: (change 4 to whatever max num of digits you want to allow)
Search array of filenames for file ending with “.txt”
I have an array with filenames. I want to check if the array have a file with extension ‘.txt’. How can I do that? in_array only checks for a specific value. Answer Contrarily to other answers suggesting array_filter, I don’t return something. I just check if it exists in the array. Besides,…
Remove double quote in json_encode()
I want remove double quote in my json_encode, that is my code: My result is that: I want to remove double quote of “id_posiciones” and “device_version” too. How can I do for the result is that: Answer If you add an underscore to your regex at the end it will do it. I assume that’…
How to read a CSV file using PHP and display content in Table/DIV?
I am using the following PHP code to read a CSV file with two column (e.g. x,y) and display the content in a table:
Hidden Input Values not being passed through form to New URL
I have a small html file working in the frame of a website. It currently requests a zip code and then calls a php page to query the database. The iframe gets the id number from the parent page and then gets the zip code from its own page. Here is the code snippet. However, When I enter the zip
Generating Password Hash In PHP 5.5 And Setting Cost Option
I know PHP 5.5 is in alpha but this class I am making is just being made in advance to utilize it’s hashing feature by using function_exists(). I checked out the password_hash documentation. The 3rd argument is for $options which currently supports two options, ‘salt’ and ‘cost’.…