Tag Archives: arrays

Como pesquisar subarrays eficiente em PHP?

$arr = array($arr1,$arr2,..);

How to search through $arr to find the one with key1 => 'something',key2 => 'something else'… Continue lendo

Tagged , | Deixe um comentário

Como incluir uma disposição aleatória com 2 variável

Meu config.php contém:

$a1="title";
$b1="text";
$a2="title2";
$b2="text2";

and I have 1.php which includes config.php….
I need to include ($a1 and $b1) ou ($a and $b) aleatoriamente.
Como posso fazer isso?
Obrigado. Continue lendo

Tagged , , | Deixe um comentário

Como converter uma matriz em um número em PHP?

I want to convert an array in one large number in PHP.
Por exemplo, I have an array $array:

$array[0] = 10;
$array[1] = 20;
$array[2] = 30;
$array[3] = 40;

I want this to be:

$one_large_number = 10203040;

Em Continue lendo

Tagged , , , , | Deixe um comentário

utilização adequada matriz em php

It was explained to me by a more senior PHP programmer that using PHP arrays is inefficient as it results in extra data copying. He then explained that you get less memory consumption and more performance by creating classes toContinue lendo

Tagged , , , , | Deixe um comentário

using arrays in where clause as an AND(not OR) operator in dynamic sql

Eu tenho 5 database tables, in each of which there is a column named UserId and relations are established over that column.

User Tabela (UserId is P.K):

UserId UserName
5      Salamander

Phone Tabela (Id is P.K)

Id UserId

Continue lendo

Tagged , , , | Deixe um comentário

how to join 2 2D arrays in php?

Eu tenho 2 2D arrays with exactly same column names. I have to join these 2 arrays.
They are associative arrays i.e; the rows of each array have indices as numbers but each column has got some names as indexContinue lendo

Tagged , | Deixe um comentário

Array transformation with PHP

I need to simplify and transform an array like this:

Array
(
    [0] => Array
        (
            [key1] => val1
            [key2] => val2
            [name] => name_val1
            [key3] => val3
            [std]  => std_val1
        )

    [1] => Array
        (
            [key1] => val1
            [key2] 

Continue lendo

Tagged , | Deixe um comentário

Busca por string e vetor de saída

Meu Código:

    $css="
    .class1{
        padding:10px 15px 0 auto;
        padding:10px 150px 0 20px;
        padding:13px 30px 10px 50px;
        padding:24px 1px 0 -20px;
    }
    ";

Function below extracts content between [acolchoamento:] e [;]

    function extract_unit($css, $start, $end){
    $pos = stripos($css, $start);
    $str = 

Continue lendo

Tagged , , | 1 Como

Confusão na atualização de dados de várias caixas de verificação

I have a list of checkboxes on a form, which updates the user’s status.
I want to do like, when new users are selected in the checkbox, then they get inserted in DB, caso contrário, if something is unchecked, mas… Continue lendo

Tagged , , | Deixe um comentário

Using arrays in str_replace

Is this valid PHP syntax? I think it may be causing the following warning:
Warning: Illegal offset type

$filterclear = str_replace($tag, '', $queryString);
$filterclear = str_replace(array('=+', '++', '+&'), array('=', '+', '&'), $filterclear);

Continue lendo

Tagged , | Deixe um comentário
64 páginas