I am wondering why this doesn’t work to assign a string to $separator: Elsewhere, $option has been assigned to some text or an empty string. (Actually, in my real life case, it’s some text, or FALSE, but either way…). $separator is TRUE instead of a string. The following accomplishes what I want, …
Tag: php
Combine and transpose multiple single-dimensional arrays into a single multi-dimensional array
I have three single-dimensional arrays and I need to combine them into one 3-dimensional array where each array in the new array contains one element of each of the three original arrays. I know how to do this using a simple loop but I was wondering if there is a faster / built-in way of doing this. here is a…
How to get selected month in jQuery full calendar?
We are using jQuery full calendar for displaying events from database. I need to display the events below the calendar according to user selected month onchange. I can get data according to event …
PHP convert XML to JSON
I am trying to convert xml to json in php. If I do a simple convert using simple xml and json_encode none of the attributes in the xml show. $xml = simplexml_load_file(“states.xml”); echo json_encode(…
Using smarty variable within {php} tags
Very simple question, is it possible to use a smarty var inside the {php}{/php} tags. I know it’s deprecated, pointless, not recommended, etc., but please, I am looking for a simple patch ! Something …
Test if a regular expression is a valid one in PHP
I am writing a form validation class and wish to include regular expressions in the validation. Therefore, the regex provided isn’t guaranteed to be valid. How can I (efficiently) check that the …
Remove Same Character once from two different string
I need help in PHP Script. I have two strings. After removing the same character from both string once, Another Two Strings example Output I tried str_replace which replace all the all the characters. Thanks for your helps Answer
Transpose 2d array, join second level with commas, and join first level with pipes
I have the following two-dimensional array: I want to convert columns to rows then reduce the matrix to a string like the following: Answer I’m assuming that you have this array: In which case, you can do this: See it working
PHP: Append to thrown exception message
Take the following function as an example of what I want to do: public function save() { $this->connect(‘wb’); try { if(!$this->lock()) throw new Exception(“Unable …
Regex to find content of the last occurence of square brackets
Hi Everybody, I’m Currently using preg_match and I’m trying to extract some informations enclosed in square brackets. So far, I have used this: /[(.*)]/ But I want it to be only the content of the last occurence – or the first one, if starting from the end! In the following: string = “…