Create a new array from row 2 of the array

Asked

Viewed 33 times

-1

I have an array of 30 lines and I want to get only index 1, this is the $arr[1], what I can already do. In the second line of my $arr[1], i have student information. How I do to pick up only that line and turn the values separated by space into a new array?

Array
(
    [Student ID] => 0
    [Student info] => McLol  CRN:Not Given  Subject:MAT  Course:2222 Section:Not Given  Desc:Research
    [Total Correct Responses] =>    
)

1 answer

0


tenta isso:

Array
(
    [Student ID] => 0
    [Student info] => McLol  CRN:Not Given  Subject:MAT  Course:2222 Section:Not Given  Desc:Research
    [Total Correct Responses] =>    
)

$new_array = explode(" ",$arr[1]['Student info']); /*o primeiro parâmetro você define o delimitador no seu caso o espaço, 
e o segundo você a string que você quer analisar;*/

In accordance with: https://secure.php.net/manual/en/function.explode.php

  • Thanks @Rodrigo! Just what I needed.

  • @J.Ty was worth brother success there in his project.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.