Jump to content

Explode and Upload filetype select


Cyto

Recommended Posts

Hi,

 

I'm exploding a list of result that are separated with comma, but I have also comma's in the value from the list. Is it possible to explode without removing the comma of the values?

Example of list:

10,24,13,145 etc.

 

Values are:

10,24

13,145

 

P.S I didn't wanted to open a new topic. Is it also possible when I browse a file to upload. I can select any file(All Files). Can it be done so I can choose only image file types?

 

Cyto

Link to comment
Share on other sites

assuming they are always in pairs

 

<?php 
$str = '10,24,13,145';
$a = explode(',', $str);
$b = array_chunk($a, 2);          // put into pairs
$c = array();
foreach ($b as $pair) {
    $c[] = join(',', $pair);
}

?>

$c contains
Array
(
    [0] => 10,24
    [1] => 13,145
)

Link to comment
Share on other sites

I thought of that at the first place, but I didn't know how. The strings come from a ajax post in a array. I'm calling the array like:

var numbers = [];

 

The post contains like this:

'10,24,13,145' etc.

Link to comment
Share on other sites

$str = "00:01:54,938", "00:03:10,900", "00:03:14,826"

$str2 = "00:01:57,974", "00:03:14,825", "00:03:17,851"

 

I could only get this from firebug in a console.log, but these are the values that I get from ajax.

Btw thx for helping me.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.