Вопрос

I have an array like this

   Array
(
    [0] => array('projectname', 'total_requests'),array('Project3' , 1),
    [1] => array('RTI' , 1),
    [2] => array('STAEP' , 3),
    [3] => 
)

I just want to remove [0]=>,[1]=>,[2]=>,[3]=> without converting this into string is it possible?

Это было полезно?

Решение

An Array can either have an index or be an associative array. This means that the array index is a string. Both methods require the index to be unique allowing the information to be accessed outside of the array.

In short: in order for you to still use it as an array it has to have the index.

Другие советы

Yes You are right the data is just like this

array (size=3)
  0 => string 'array('RTI' , 1),' (length=17)
  1 => string 'array('STAEP' , 3),' (length=19)
  2 => string ')' (length=1)

But i want data in this format

Array(array('projectname', 'total_requests'),
     array('Project3' , 1),
     array('RTI' , 1),
     array('STAEP' , 3),

)

without "0=>string" is it possible.

Basically my data is like this

Array
(
    [0] => Array
        (
            [projectname] => Project3
            [total_requests] => 1
        )

    [1] => Array
        (
            [projectname] => RTI
            [total_requests] => 1
        )

    [2] => Array
        (
            [projectname] => STAEP
            [total_requests] => 3
        )

)

And i want to change that data into this format using string

$mystring=" array(array('projectname', 'total_requests'),";
foreach($result as $value)
{
    $mystring.= 'array('.'\''.$value['projectname'].'\''.' , '.$value['total_requests']."),";
}
 $mystring.=')';

I got the desired result but it is in String i want this result in array

array(
        array('projectname', 'total_requests'),
        array('Project3', 1),
        array('RTI', 1),
        array('STAEP', 3),
    ),
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top