0

one other question

$_SESSION['files'][] = $sid . '-' . $data['Id'] . '-reg'
$_SESSION['files'][] = $sid . '-' . $data['Id'] . '-nor'
...

the files session should look like this when echoed

317e2b5a2376dd19cb5fc431bced949a-56-reg

how do i take $_SESSION['files'][] and separate the data into these variable $sid, $id, $type using - and the separator... something like this.

$sid = "317e2b5a2376dd19cb5fc431bced949a";
$id = "56";
$type = "reg";

following codaddict below example something like this would be right correct?

for($i=0;$i<count($_SESSION['files']);$i++) {
list($sid,$id,$type) = explode('-',$_SESSION['files'][$i]);
...
}

2 Answers 2

2

You can use explode:

list($sid, $id, $type) = explode('-', $filename, 3);

Or sscanf:

sscanf($filename, '%s-%s-%s', $sid, $id, $type);
Sign up to request clarification or add additional context in comments.

Comments

2

You can use explode function as:

list($sid,$id,$type) = explode('-',$_SESSION['files'][$index]);

Ideone link

1 Comment

does this look right for my For statement? for($i=0;$i<count($_SESSION['files']);$i++) { list($sid,$id,$type) = explode('-',$_SESSION['files'][$i]); ... }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.