Skip to content

Tag: php

Regex get all numbers before colon

I have the folling string: I want to get all numbers before the colon and return an array with them. So for the given string i would get the following: Answer You can use this lookahead based regex in preg_match_all: Code: RegEx Demo

PHP PDO::FETCH_ASSOC returns false

In this code fetch(PDO::FETCH_ASSOC) retunrs false even if $row>0. I couldn’t find why this is happening. Here session is not set as $member is null. <?php $sql = "SELECT * FROM members WHERE …

How to get some part of text from a large text

Is there any way to get get a small part of data from an array index in php? For example, I have an array of data like: Array( [title] => My title [description] =>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever…

Encoding for SMS messages

I’m currently building an application which uses Nexmo to send SMS messages to users. But I’m experiencing some problems with the encoding of messages. Probably worth metioning; I’m using the prawnsalad/Nexmo-PHP-lib library to connect with their API. A simple text messages of 160 characters…

Select box with first option empty

How can I set the first option in my select box to an empty value? I’m getting the data from my DB, and I would like to set the option by default as “Please select one option”. Answer I found that ‘default’=>’Please select’ doesn’t work with the HTML5 require…

PHP code convert to PHP/MySQLi OOP

today i tried to convert my code to PHP/MySQLi OOP code. class Database { private $host; private $user; private $password; private $db; private $mysqli; function __construct() { $this->host = …