Questions tagged as 'php'

4
answers

How to remove parentheses from values in an array?

I have an array and I need to remove all parentheses from all the values of this array. Follow the array: $array = array( "chave1" => "(valor1)", "chave2" => "(valor2)", "chave3" => "(valor3)" ); I need you to look li...
asked by 03.01.2017 / 13:20
3
answers

How can I make a rand () that always generates only 4 random numbers?

How can I make a rand() that always only generate 4 random numbers, eg: 4562, 9370, 1028 ... My code it generates up to 4 numbers, but it has 3 times. $presenca = rand() % 4000;     
asked by 26.10.2017 / 15:19
3
answers

System of categories and subcategories / infinite children

I'm building a system of infinite, simple categories and subcategories. I found a script on the internet that meets the requirements, but its customization and adaptation to my project made it almost unusable. I studied a simple structure and...
asked by 14.04.2014 / 01:31
3
answers

jQuery - Typical duplicate use situation of the same code. How to proceed?

Being here doing my sites in php/mysql/html/css and learning more and more about jQuery I got into the situation where I should use the same code for two ids distinct. How do I need to use the same code in two different p...
asked by 09.08.2014 / 20:05
2
answers

Why omit the PHP closing tag?

Every good good practice book and wiki starts with this "rule" but no one offers good reasons. What good reasons to ignore the ?> PHP closing tag?     
asked by 04.05.2015 / 21:41
3
answers

How to filter data entries in PHP

Good evening, I have a form serving data entry that is displayed on the screen. The problem is that this data can be html tags or scripts, if someone puts this code in my form, the page will be redirected. <meta http-equiv="refresh" content...
asked by 16.02.2015 / 04:33
2
answers

Exit two Foreachs PHP

I need to iterate several collections and if I find a condition I have to exit more than one iteration loop. Ex: foreach ($order->getItemCollection() as $item) { foreach ($order->getFreight()->getPackageCollection() as...
asked by 06.10.2014 / 20:47
1
answer

Creating PHP object from HTML

I imagine that frameworks usually do the following to create a simple text field: $campoTexto = new CampoTexto("nomeDoCampo", "valorDoCampo"); $campoTexto->gera(); The result would be: <input type="text" name="nomeDoCampo" value="va...
asked by 26.06.2014 / 21:18
1
answer

Error trying to convert Portuguese date into datetime

I have a problem and I can not find a solution to fix it. I have a date in this format: Wednesday, April 30, 2014 and I want to save this date in the database in type datetime . So I am trying to convert to type datetime , but I h...
asked by 30.04.2014 / 17:50
3
answers

Error "HTML contains invalid UTF-8 character (s)" when using mpdf

I have a problem using mPDF. Basically, I have a code that makes a select of a table and then displays the values on a PDF page. The problem is that if any table value has an accent (example: "Hello") the error appears:    "HTML con...
asked by 06.07.2014 / 15:57