PHP Convert Windows-1251 to UTF 8

Tags: , , ,


I have a small html code and I need to convert it to UTF-8. I use this iconv(“windows-1251”, “utf-8”, $html); All text converts correctly, but if text for example in tag , then …

Tags:

utf8 not showing hyphens correctly in echoed text


my MySQL database is set to utf8_unicode_ci and I have $pdo->exec(‘SET NAMES “utf8″‘) as part of the following php code yet when I echo text from the query a hyphen – looks likes this –. What am I …

Tags: php

Add a new index to multidimensional array

Tags:


I have a multidimensional array. ie. Array ( [0] => Array ( [item_id] => 1 [item_name] => x ) [1] => Array ( […

Tags: html php

Delete html elements with php

Tags: ,


I was wondering if I had an HTML page, how would I delete an element with php, by the name or id of it. so I could have HTML code like this

Tags: php symfony twig

Symfony2 / Twig – getting array from dynamic array key

Tags: , ,


In PHP I would do this: foreach( $array as $key => $value ) { echo $another_array[$key]; } I can’t see how to do that in Twig (in Symfony2). I’ve tried various things, but this would seem …

Tags:

How to add square braces around subarray data inside of a json encoded string?


When trying to access an API the JSON array must be parsed like this {“item”:[{“id”:”123456″, “name”:”adam”}]} But when i’m doing the following code $data = array(“item” => array(“id” => “…

Tags: mysqli php

new mysqli(): how to intercept an ‘unable to connect’ error?

Tags: ,


I’m doing this (yes, I’m using wrong connection data, it’s to force a connection error ) try { $connection = new mysqli(‘localhost’, ‘my_user’, ‘my_password’, ‘my_db’) ; } catch (Exception $e ) { …

Tags: namespaces php

PHP Namespace Syntax: What is the Difference with Braces vs. without Braces?

Tags: ,


PHP offers two syntax for declaring namespaces. You can use a namespace with no braces or with braces as seen below. Without Braces namespace foo/bar; class Any{} With Braces namespace foo/bar { …

Tags:

Preg_match identifier


I want ot get a match from my identifier. I have a string like this coming in {/describe:foo} where I am trying to match {/describe:} to return foo, but am not getting the regex right, would someone …

mysql custom global defined variable

Tags: , ,


In my database design, I tend to store some variable that is meant to be acting as a ROLE or TYPE as SMALLINT. For example : CREATE TABLE `house` ( `id` int(11) NOT NULL AUTO_INCREMENT, `type` …