Tag Archives: array

How to search through subarrays efficiently in PHP?

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

How to search through $arr to find the one with key1 => 'something',key2 => 'something else'… Continua a leggere

Tagged , | Lascia un commento

Come includere un array casuale con 2 variabile

Il mio config.php contiene:

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

and I have 1.php which includes config.php….
I need to include ($a1 and $b1) o ($a and $b) in modo casuale.
Come posso fare questo?
Grazie. Continua a leggere

Tagged , , | Lascia un commento

How to convert an array into a number in PHP?

I want to convert an array in one large number in PHP.
Per esempio, 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;

In Continua a leggere

Tagged , , , , | Lascia un commento

proper array use in 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 toContinua a leggere

Tagged , , , , | Lascia un commento

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

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

User Tavolo (UserId is P.K):

UserId UserName
5      Salamander

Phone Tavolo (Id is P.K)

Id UserId

Continua a leggere

Tagged , , , | Lascia un commento

how to join 2 2D arrays in php?

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

Tagged , | Lascia un commento

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] 

Continua a leggere

Tagged , | Lascia un commento

Ricerca di stringhe e array di uscita

Il mio Codice:

    $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 [padding:] e [;]

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

Continua a leggere

Tagged , , | 1 Come

Confusione in aggiornamento dei dati da più caselle di controllo

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, in caso contrario, if something is unchecked, ma… Continua a leggere

Tagged , , | Lascia un commento

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);

Continua a leggere

Tagged , | Lascia un commento
64 pagine