Skip to content

Tag: php

rtrim with underscore in php

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’…

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…

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 …

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…