Posts by Marcos Xavier • 698 points
38 posts
-
0
votes2
answers57
viewsA: Search PHP array value
Here are two examples that can give you an overview of how to solve your problem. Test here https://3v4l.org/uPRHp <?php $items = [ ["item_a" =>3,"valor_a" =>396], ["item_a"…
-
0
votes2
answers30
viewsA: Get default response if it does not exist in Laravel’s Wherein
Following the same line of reasoning of @Ademir-Mazer-Jr-One I will leave a reply to enrich the post. https://paste.laravel.io/873076f6-e386-4222-b225-44bd15b6aa97 $item_ids = [1, 2, 4]; //simulando…
-
-1
votes2
answers57
viewsA: How to receive with $_POST in PHP a value that was sent via Urlsearchparams (urlencoded) with Javascript Vanilla fetch?
O . then and . catch treat the backend response Data is not coming when I try to pick up $_POST. I reproduced something similar to what you probably use in your Vanilla JS <?php // test.php…
-
2
votes1
answer28
viewsA: Create table from an array by making the keys the header
Basically you would need to check that $records is not empty and retrieve the keys from the first $records item. Here is an example. Array Keys -…
-
-4
votes1
answer49
viewsA: PHP - Sum of hours for point system
I assumed that you are only used this for study purposes so I will not put into debate that this is not the best way to store time to perform calculations with hours, days etc to avoid Pogs like…
phpanswered Marcos Xavier 698 -
0
votes1
answer49
viewsA: How to prevent all items from exiting the screen when animating using Translate?
I made an example here based entirely on what you posted. I changed the Switch from myBtn2 as below and in the tests I performed here worked correctly. Edit. I added the function isElementInViewport…
-
0
votes1
answer149
viewsA: How to redirect from one page to another in Laravel?
Hi, welcome to the O.R. I recommend reading about named Routes (routes named in en) and on the helper route. Done that come on There is no route to /register and yes to /pre-registration, so the Not…
-
1
votes2
answers45
viewsA: How to show the error message of validating a data on the screen with append?
I will leave a small source for study and better understanding of the ajax request using jquery. For this post I used this fake api for testing https://jsonplaceholder.typicode.com/ View logs in the…
-
0
votes1
answer47
viewsA: Count php/js characters
Welcome to the OR. I made a very simple example, I think it will help you. I kept the html you sent and removed the inline javascript. <tr> <td colspan="3"><b>Descreva aqui suas…
javascriptanswered Marcos Xavier 698 -
0
votes2
answers772
viewsA: Return JSON PHP POST query
I have a simpler method with file_get_contents. Do a test there. <?php $url = 'http://mobi.ieptb.org.br/consulta'; $body = '{"cpf_cnpj": "83899526000182"}'; $opts = [ 'http' => [ 'method'…
-
1
votes5
answers583
viewsA: How to sort json in php
If it’s Laravel let’s do it the Laravel way, using Collection you can do something like below. $a = '[ { "unidade": "124", "bloco": "Bloco B" }, { "unidade": "21", "bloco": "Bloco A" }, { "unidade":…
-
0
votes3
answers4175
viewsA: How to change a PHP array’s key
In the Laravel way. I used the contracted syntax of the $array = ['...']; ( available from PHP 5.4 https://secure.php.net/manual/en/language.types.array.php ) $task = ['Title' => 'Test',…
-
10
votes2
answers905
viewsA: How does PHP foreach work?
I researched a little about and came to the following conclusion., Test 1: Restarting the array’s internal pointer with each iteration not causes the loop to restart A - Approximate translation:…
-
-1
votes2
answers140
viewsA: Function does not recognize checkbox.checked
I have two ideas. A very similar answer above. Test the two that your understanding on the subject will improve. <script…
-
0
votes3
answers791
viewsA: Take a value of multiple arrays within an array
Simple. $novoArray = array_column($seuArray,'membro_id'); print_r($novoArray); It can be interesting using the third parameter where the array is returned with the key=>value. Example: $novoArray…
-
0
votes2
answers67
viewsA: Check how many dates are equal
Prefer to use the PHP Datetime object. <?php $hoje = DateTime::createFromFormat('Y-m-d',date('Y-m-d')); $datafinal = DateTime::createFromFormat('Y-m-d','2018-07-05'); $datasIguais =0; //…
phpanswered Marcos Xavier 698 -
1
votes1
answer100
viewsA: How to use http://loudev.com/ (multiselect.js) in PHP, or how to select items from a select Multiple
Here is a simple example to bring the selected options. echo '<select multiple="multiple" id="chkImp" name="chkImp[]" class="form-control" required>'.PHP_EOL; foreach($impressoras as $value):…
-
1
votes1
answer1328
viewsA: Check if it is authenticated
In your view you can do the following: @if(Auth::check()) //Conteúdo protegido @endif @if(Auth::guest()) //Conteúdo para não logado(um form de login etc) @endif Anyway, there are other ways to do…
-
0
votes1
answer103
viewsA: Cakephp: Problems with routing and paging
Modify page:page for :page Router::connect( '/Produtos/index/:cat/:id/:page', [ 'controller' => 'Produtos', 'action' => 'index' ], [ 'pass' => ['id', 'cat', 'page'], 'id' => '[0-9]+',…
-
0
votes4
answers1700
viewsA: Understanding Node and Applications in Real-Time
Node integration with Cakephp or other rayls-like framework is not possible? It is fully possible to use Cakephp with Node. I recently implemented a notification system and a chat (both Altime)…
-
2
votes1
answer1751
viewsA: Delete last line in white txt php
This will resolve. Any blank lines will be removed. Remember that a space is not a blank line, just in case, modify the values of the array that are with spaces. <?php $lines =…
-
1
votes3
answers859
viewsA: I am suffering attacks of type SQL Injection
Avoid using mysqli_* and mysql_* functions, use PDO, process data entries. Makes a select in your bank and check the privileges of users, if there are any "strange" users, if root has external…
-
0
votes3
answers331
viewsA: PHP remove a URI snippet with regular expression
If the order parameter is alphanumeric you can use the following example. Ps. Posted here for comments not to extend too much Run in https://regex101.com/r/YIR8IP/2 $re =…
-
5
votes3
answers182
viewsA: Convert date type 2016-10-04 15:51:16 to, 04-10-2016 15:51:16 to SQL or PHP how to do?
With PHP: //para testar //$dateObj = new DateTime('2016-10-04 15:51:16'); $date = $linharesp['data']; $dateObj = new DateTime($date); echo $dateObj->format('d-m-Y H:i:s'); With SQL (note that I’m…
-
0
votes3
answers1413
viewsA: How to check if a snippet of a string is in an array item
A simpler example, I believe it answers you. $array = "facebook.com, google.com, twitter.com"; $ref = "http://m.facebook.com"; $arrayIds = explode(',', $array); if (in_array($ref,$arrayIds)){ echo…
phpanswered Marcos Xavier 698 -
3
votes7
answers22208
viewsA: Is using MD5 the safest way to encrypt passwords in PHP?
Very well put the answer of @daniel-Omine. I agree that the md5 is not so insecure, no use having a super-secure login system, which blocks multiple login attempts, etc if we have you user. I’ve…
-
5
votes4
answers5008
viewsA: Odd or even array in PHP
I leave my contribution with array_map function checarNumeros($numeros){ return ($numeros % 2 ) ? TRUE : FALSE; } $parOuImpar = array(2,3,4,56,5,42,98,100); $array = array_map("checarNumeros",…
-
1
votes7
answers1134
viewsA: Select a file by name in PHP
With strstrstr is also possible. http://php.net/manual/en/function.strstr.php <?php $filename = '20160111_ALGUMA_COISA.txt'; //omitindo o terceiro parâmetro - default false-(retornaria…
-
1
votes1
answer60
viewsA: Data passed via Function
If the form method is POST, for file inputs use $_FILES instead of $_POST <?php //Chama a função inserir caso tenha algum dado em POST (includes/conexao) if (isset($_POST['salvar'])) {…
-
1
votes3
answers474
viewsA: Getting Output Terminal History on Ubuntu
There is another way and I cannot help but comment. In the personal folder there is a file called . bash_history(/home/user/.bash_history). If you open from Nautilus, give a Ctrl+h to display the…
-
1
votes3
answers2423
viewsA: Calculation of growth percentage
If I understand the question, the formula for calculating this is: x = past recipe - current recipe / past recipe revenue = x * 100 In the link below, there are more complex examples.…
-
0
votes7
answers175
viewsA: Contact Form
The code below should suit what you need $phone ="912341234"; $phone = isset($phone[8]) && is_numeric($phone) ? $phone : null; if ($phone ===null ){ echo "invalido"; } else{ echo "valido"; }…
-
2
votes8
answers1132
viewsA: Can you use a variable above when it is declared below?
Capturing the value passed via get is possible. <!DOCTYPE html> <html lang="pt-br"> <head> <title> <?php $pagina= isset($_GET['pagina']) ? $_GET['pagina'] : "Inicial";…
phpanswered Marcos Xavier 698 -
2
votes2
answers1006
viewsA: How to install Zftool (windows, linux)
Since the topic is about zend why not for Linux as well? For Linux (versions based on Debian): Launch the terminal and navigate to your server’s root directory (in my case /var/www): $ cd /var/www $…
-
4
votes2
answers234
viewsQ: Update on Zend 2
I’m studying Zend Framework 2 and I’m needing a hand to do an update on two tables that are related. Come on. I have the table entries with the fields: id_entrada id_notafiscal and in the rating…
-
1
votes2
answers1978
viewsA: Problems with dpkg in Linux Mint
I’ve been there, too. Tries: sudo apt-get clean && apt-get update Otherwise try to: sudo rm /var/lib/apt/lists/* -vf sudo apt-get update…
-
0
votes5
answers620
viewsA: How to select records that have a relationship with all values in a list?
I believe that using Internet and group by you solve.Follows: SELECT cp.id, cp.nome FROM cp_pessoa as cp inner JOIN cp_habilidade_freelancer as chf ON ( chf.id_freelancer=cp.id) left JOIN…
-
2
votes7
answers3667
viewsA: PDO does not connect to Mysql
On linux, type in the terminal: php -i | grep drivers And make sure the driver is enabled. On Debian/Ubuntu based systems the installation is simple, on the terminal type: //para instalar sudo…