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
Tag: php
Having Trouble in Generating Amazon AWS Signature With PHP
I was trying to make a HTTP POST Request to amazon’s AGCOD Service API , I followed all the steps to make a signature and all the hashed keys matched the instructions here, but I still got a “The …
Set Expected Exception in Codeception Functional Cept
I want to do something like: In a functional cept. Any chance to do so? Above code will work in isolation but if I run codecept run, the tests get stuck once the test with the expected exception is complete. Here’s my setup: YML: Answer I think this is a known problem with the Laravel 4 module for codec…
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…
Guzzle Service Description How to have Comma Deliminated Array?
is there a way to automatically have a Guzzle Service Descriptor field, take an array, and it’ll parse it to a comma list? Data Array [ “test”, “another test” ] Service Descriptors The field is the id under parameters, I’d like to provide the raw php array of strings to tha…
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…
how to delete completed orders in woocommerce using a my sql query
I want to delete completed all orders in woocommerce by using a single my sql query. Because, I’m having a problem with my WordPress Dashboard. I can’t view the completed orders from the back-end. It’…
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 = …