I have line as ‘Delux Room_room’. I want get ‘Delux Room’ as result. I tried following codes. Following code give following result. Result ;- But i want Delux Room. Please help me. Answer That says “remove characters from the end of the string until you get to one that isn’…
Tag: php
How do I ensure I caught all errors from MySQLi::multi_query?
The docs for multi_query say: Returns FALSE if the first statement failed. To retrieve subsequent errors from other statements you have to call mysqli_next_result() first. The docs for next_result say: Returns TRUE on success or FALSE on failure. Finally, the example posted in the docs for multi_query use the…
Get Last Part of URL PHP
I’m just wondering how I can extract the last part of a URL using PHP. The example URL is: Now how can I extract the final part using PHP? There is always the same number of variables in the URL, and the id is always at the end. Answer You can use preg_match to match the part of the URL
Right justifying with printf
I’ve got a dictionary where both the keys and values are strings. I would like to print each key-value pair on its own line with the key left justified and the value right justified. Etc… What’s the best way to do this in PHP? Perhaps a clever way to do with printf? Answer Try this: The 40 t…
Split string on non-alphanumeric characters and on positions between digits and non-digits
I’m trying to split a string by non-alphanumeric delimiting characters AND between alternations of digits and non-digits. The end result should be a flat array of consisting of alphabetic strings and numeric strings. I’m working in PHP, and would like to use REGEX. Examples: ES-3810/24MX should be…
SMS sending through free gateway
Please guide me with sample code for sending sms through website. How to include sms gateway. Please tell me, can i use way2sms.com as gateway? is it the right way to use? please suggest me only this …
Magento Custom Payment Method: how to get data that was set via Mage_Payment_Model_Method_Abstract::assignData()?
I’m currently developing a payment method and things are working quite well. Just one thing: The customer enters some information along the payment method and through debugging I can see that it gets written into the InfoInstance via Mage_Payment_Model_Method_Abstract::assignData() Unfortunately, I can&…
HTMLENTITIES doesn’t work with cyrillics
How can I make htmlentities to work with cyrillic symbols. Now, when I try input some cyrillic: “Тест” it returns “Теє My code: $var = htmlentities($var); Encoding: utf-8. Thanks! Answer In order to bring closure to this question – I want my users not to enter HTML code in the…
Search with full name instead of just first name or last name
I am developing an API built with PHP and Codeigniter and I use MySQL as database. I have a user table called Users which contains the following columns: How can a user search this table using a full name? For example it works fine to search either by Martin or Smith, but not Martin Smith. This is the query I
Short Text, PHP
I got this function: and if I use echo shorter($input, 11) it works ok, but if there are some white spaces in the input, otherwise for the input looking like: wwwwwwwwwww The function will change this into: … (3 dots). I wan’t it to be changed into something like this: www … Have you got any…