Questions tagged as 'php'

2
answers

How to remove a character repeated in sequence?

How do I remove the repeated characters in sequence with PHP? Entry:    Ellizabetth Output:    Elizabeth     
asked by 10.08.2016 / 21:06
3
answers

Foreach Array by incrementing another array

With a question about foreach and incrementing another helper to perform an insert in the database, see: When I send a form via post I get the following array as a result: array (size=2) 'quantidade' => array (size=8) 0 =>...
asked by 14.11.2016 / 12:43
4
answers

How can I generate a 7-character alphanumeric key?

How can I generate a key with 7 alpha-numeric characters, completely random in PHP? In other words, I want to make a key with completely random numbers and capital letters. I've tried using the rand, but the rand only generates numbers.  ...
asked by 07.07.2016 / 04:52
2
answers

What happens if I do not specify {}?

I have this code that works normally: if($time <= time()) { if($time != 0) $Server->wsSend(1, 'perfect world'); foreach ( $Server->wsClients as $id => $client ) $time = time() + $adminMess...
asked by 15.03.2015 / 16:52
2
answers

PHP on linux or windows

Explanation: I know it's a controversial question, but I'm not an old man of the programming and I'm knowledgeable about linux, but I've never chosen it because I use C # from time to time and in my college they are pro-microsoft. So the wo...
asked by 01.05.2015 / 06:03
3
answers

PHP failed echo

Because this: echo 1 ^ 2; is equal to 3? And because this: echo 0x33, ' birds sit on ', 022, ' trees.'; It looks like this: "51 birds sit on 18 trees"?     
asked by 24.10.2017 / 20:49
4
answers

What's the difference in using sprintf in relation to using variables within the string?

Looking at some libraries and examples, it is common to find sprintf in some situations that I find strange. Reading your documentation I noticed that there are several types of formatting , however I see some cases that I do not see...
asked by 18.01.2017 / 01:21
1
answer

Move string and replace a specific PHP character

I wanted to replace, in a string, all occurrences of the & character with a e (or remove it). The character may be in the middle of a word or appear multiple times in the same string. Example:    Original value: John went...
asked by 26.05.2014 / 10:09
4
answers

Include UTF-8 charset in mysqli connection

Hello, after repairing my code is full of strange characters like ???, I tried to fix it but I discovered that I need to change the charset through the mysqli connection, but the problem is that I do not know how to do this! Can anyone help m...
asked by 30.07.2015 / 20:37
3
answers

How to connect to MySQL only once, without ever having to instantiate?

How do I connect to MySQL only once, without having to re-write it in every function? Currently I do this: class Site { var $driver; var $host; var $dbname; var $user; var $pass; public function __construct($driver,...
asked by 08.12.2014 / 14:51