Skip to content

Instantly share code, notes, and snippets.

View YurePereira's full-sized avatar
😀
Out sick

Yure Pereira YurePereira

😀
Out sick
View GitHub Profile
@YurePereira
YurePereira / for_array.php
Last active February 12, 2017 18:11
Iterando Array pela estrutura de repetição FOR.
<?php
//Array de elemento de String
$myArray = array(
'item_1',
'item_2',
'item_3',
'item_4',
'item_5',
'item_6',
@YurePereira
YurePereira / using_foreach_in_array.php
Last active February 12, 2017 18:10
Iterando Array com FOREACH primeira sintaxe
<?php
//Array de elemento de String
$myArray = array(
'item_1',
'item_2',
'item_3',
'item_4',
'item_5',
'item_6',
@YurePereira
YurePereira / iteration_foreach_array_second_syntax.php
Created February 12, 2017 18:57
Iterador Arrays com FOREACH no PHP segunda sintaxe
<?php
//Array de elemento de String
$myArray = array(
'item_1',
'item_2',
'item_3',
'item_4',
'item_5',
'item_6',
@YurePereira
YurePereira / array_union_operator.php
Last active February 13, 2017 14:53
Fazendo a união dos Arrays $firstArray e $secondArray retornado um novo Array.
<?php
$firstArray = array(
'r' => 'Red',
'b' => 'Blue',
'y' => 'Yellow',
);
$secondArray = array(
'b' => 'Black',
@YurePereira
YurePereira / using_equal_and_identity_operator_array.php
Last active February 13, 2017 15:40
Usando o operador de igualdade e identidade de Array.
<?php
$firstArray = array(
'b' => 'Black',
'w' => 'White',
'g' => 'Gray',
);
$secondArray = array(
'g' => 'Gray',
@YurePereira
YurePereira / using_other_operators.php
Created February 13, 2017 16:34
Unsando os operadores de desigualdade e não identidade de Arrays.
<?php
$firstArray = array(
'b' => 'Black',
'w' => 'White',
'g' => 'Gray',
'p' => 'pink',
);
$secondArray = array(
@YurePereira
YurePereira / add_elements_dynamically_in_array.php
Created February 14, 2017 15:43
Adicionando elementos dinamicamente a um Array.
<?php
$myArray = array();
//Adicionando elementos a nosso Array dinamicamente,
//sem definir sua chave, assim ela será gerada automaticamente:
$myArray[] = 'blue';
$myArray[] = 'red';
//Adicionado elementos definindo sua chave de acesso:
@YurePereira
YurePereira / using_file_exists.php
Created February 15, 2017 16:52
Utilizando o função file_exists no PHP.
<?php
//Caminho do arquivo
$path = '../my_folder_name/my_filename.php';
//Retornará true se o arquivo existir
if (file_exists($path)) {
//Se o arquivo existir podemos incluí-lo.
include($path);
@YurePereira
YurePereira / include_file_with_relative_path.php
Last active February 7, 2020 21:38
Pegando o caminho relativo à esse arquivo.
<?php
//Pegando o caminho relativo à esse arquivo.
$path = 'components/';
$file = $path . 'header.php';
include($file);
@YurePereira
YurePereira / including_files_absolute_path.php
Created February 18, 2017 16:33
Incluindo arquivos com caminho absoluto no PHP.
<?php
$path = dirname(__FILE__) . '\components\\';
//Ou também:
//$path = __DIR__ . '\components\\';
$file = $path . 'header.php';
include($file);