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 / using_array_map.php
Created March 4, 2017 21:59
Convertendo todos as strings de um Array para uppercase.
<?php
$listFrults = array(
'Pineapple',
'Cashew',
'Apple',
'Strawberry',
'Pear',
'Coconut',
'Grape',
@YurePereira
YurePereira / using_array_key_exists.php
Created March 4, 2017 14:10
Verificando se uma determinada chave de índice existe dentro de um Array.
<?php
$listFrults = array(
'p' => 'Pineapple',
'c' => 'Cashew',
'a' => 'Apple'
);
if (array_key_exists('c', $listFrults)) {
echo 'Chave existente.';//Bloco que será exibido.
@YurePereira
YurePereira / using_array_key_exists.php
Created March 2, 2017 15:45
Verificando se uma chave existe dentro de um Array em PHP.
<?php
$listFrults = array(
'p' => 'Pineapple',
'c' => 'Cashew',
'a' => 'Apple',
'o' => 'Orange'
);
if (array_key_exists('a', $listFrults)) {
@YurePereira
YurePereira / using_in_array_2.php
Last active March 1, 2017 22:12
Verificando se um valor existe dentro de um Array em PHP - Exemplo 2.
<?php
$listFrults = array(
'pineapple' => 100,
'cashew' => 900,
'orange' => 500,
'strawberry' => 230
);
if (in_array('900', $listFrults, true)) {
@YurePereira
YurePereira / using_in_array.php
Last active March 1, 2017 22:13
Verificando se um valor existe dentro de um Array em PHP.
<?php
$listFrults = array(
'Pineapple',
'Cashew',
'Coconut',
'Orange',
'Strawberry'
);
@YurePereira
YurePereira / using_array_merge.php
Created March 1, 2017 16:20
Usando a função array_merge no PHP exemplo 2.
<?php
$listFrults1 = array(
'p' => 'Pineapple',
'c' => 'Cashew',
'a' => 'Apple',
'o' => 'Orange'
);
$listFrults2 = array(
's' => 'Strawberry',
@YurePereira
YurePereira / using_array_merge_2.php
Created March 1, 2017 16:14
Usando a função array_merge no PHP exemplo 2
<?php
$listFrults1 = array('Pineapple', 'Cashew', 'Coconut', 'Orange');
$listFrults2 = array('Strawberry', 'Pear', 'Grape', 'Peach');
$listFrults3 = array('Lime', 'Apple', 'Kiwi Fruit', 'Mango');
$listFullFrults = array_merge($listFrults1, $listFrults2, $listFrults3);
print_r($listFullFrults);
@YurePereira
YurePereira / using_include_once_and_require_once.php
Created February 26, 2017 17:15
Usando include_once e require_once no PHP.
<?php
//Caminhos dos arquivos a serem incluídos.
$path1 = '<path>/filename_1.php';
$path2 = '<path>/filename_2.php';
//Usando a função include_once:
include_once($path1);
//O arquivo no $path1 não será incluído, pois ele já foi.
include_once($path1);
@YurePereira
YurePereira / using_require.php
Created February 26, 2017 15:15
Usando a função require no PHP.
<?php
//Caminho do arquivo a ser incluído.
$path = '<path>/filename.php';
//Fazendo inclusão do arquivo.
require($path);
@YurePereira
YurePereira / using_include.php
Created February 26, 2017 15:09
Usando a função include no PHP
<?php
//Caminho do arquivo a ser incluído.
$path = '<path>/filename.php';
//Fazendo inclusão do arquivo.
include($path);