Questions tagged [explode]

explode() is a PHP function that splits a string based on a delimiter, returning an array.

explode() is a PHP function that splits a string based on a delimiter, returning an array.

array explode ( string $delimiter , string $string [, int $limit ] )

Example

$text = "a b c d";
print_r(explode(" ", $text));

gives:

Array ( [0] => a [1] => b [2] => c [3] => d )
2123 questions
3
votes
4 answers

Exploding strings in PHP

I have the following bit of PHP code. Ultimately, I'd like to store

Michael is 26

in the $str1 variable and

He likes green cars.

And white footballs

And red lollies

And yellow suns

in the $str2 variable. So basically…
michaelmcgurk
  • 6,367
  • 23
  • 94
  • 190
3
votes
4 answers

$_POST a input value in two parts (explode?)

I'm really new to PHP, so this is probably a pretty dumb question. I'm using PHP to submit an email form, and would like the email to contain the values of some of the form's inputs. Here's a stripped down version:
Tomas Mulder
  • 2,207
  • 2
  • 16
  • 18
3
votes
3 answers

pyspark explode performance

Background I use explode to transpose columns to rows. This works very well in general with good performance. The source dataframe (df_audit in below code) is dynamic so can contain different structure. Problem Recently have incoming dataframe with…
B Mart
  • 51
  • 1
  • 6
3
votes
6 answers

Remove all characters starting from last occurrence of specific sequence of characters

I am parsing out some emails. Mobile Mail, iPhone and I assume iPod touch append a signature as a separate boundary, making it simple to remove. Not all mail clients do, and just use '--' as a signature delimiter. I need to chop off the '--' from…
scott
3
votes
2 answers

How to expand and create the following dataset in Pandas

I have a dataset that looks like this: df = pd.DataFrame({ 'weekstart':['01-Jan-18','08-Jan-18','15-Jan-18','22-Jan-18'], 'weekend':['07-Jan-18','14-Jan-18','21-Jan-18','28-Jan-18'], …
3
votes
2 answers

How to use multiple separators in a pandas Series and split into multiple rows

I have a dataframe like this. df = pd.DataFrame({ "Name" : ["ABC LLC Ram corp", "IJK Inc"], "id" : [101, 102] }) Name id 0 ABC LLC Ram corp 101 1 IJK Inc 102 I am trying to split the Name series into…
Pyd
  • 6,017
  • 18
  • 52
  • 109
3
votes
1 answer

Regex | explode | str_split to match number in a title

I'm giving an example so you can understand what I want to achieve. I got this titles: $t1 = "Disposizione n. 158 del 28.1.2012"; $t2 = "Disposizione n.66 del 15.1.2006"; $t3 = "Disposizione f_n_66 del 15.1.2001"; $t4 = "Disposizione numero 66 del…
Marinario Agalliu
  • 989
  • 10
  • 25
3
votes
1 answer

giving array values with double quotes PHP

i have this json array code in php $url = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-6.893238,107.604273&radius=100&type=point_of_interest&keyword=oleh-oleh&key=mykey"; $data = file_get_contents($url); $json =…
3
votes
3 answers

How to use two columns to distinguish data points in a pandas dataframe

I have a dataframe that looks like follow: import pandas as pd df = pd.DataFrame({'a':[1,2,3], 'b':[[1,2,3],[1,2,3],[1,2,3]], 'c': [[4,5,6],[4,5,6],[4,5,6]]}) I want to explode the dataframe with column b and c. I know that if we only use one…
Yun Tae Hwang
  • 1,249
  • 3
  • 18
  • 30
3
votes
3 answers

Explode Array into Multidimensional Arrays (parent->child->sub-child)

I've got an array ($categories_final), looks similar to this: Array ( [0] => Accessories/Apron [1] => Accessories/Banners [2] => Accessories/Belts [3] => Brand/Brand1 [4] => Brand/Brand2 [5] => Apparel/Men/Belts [6] =>…
3
votes
1 answer

Pyspark - How to duplicate/triplicate rows?

I need to "clone" or "duplicate"/"triplicate" every row from my dataframe. I didn't find nothing about it, I just know that I need to use explode. Example: ID - Name 1 John 2 Maria 3 Charles Output: ID - Name 1 John 1 John 2 …
thalesthales
  • 95
  • 1
  • 7
3
votes
1 answer

Expand pandas dataframe date ranges to individual rows

I have to expand a pandas dataframe based on start date and end date, into individual rows. Original dataframe is as below My final dataframe should be repeated for each day between start and end date of individual rows.The result needs to be…
NeatCoder
  • 43
  • 1
  • 5
3
votes
5 answers

PHP explode function with file_get_contents?

The above code prints an array as an output. If I use
user244333
3
votes
5 answers

How to cast string into array with only characters in double quotes

I need to cast $string = ("one","two","three,subthree","four") into PHP array like. $data[0] => "one", $data[1] => "two", $data[2] => "three,subthree", $data[3] => "four" The issue is that the delimiter in 3rd variable contains comma so explode…
Wajahat
  • 53
  • 7
3
votes
4 answers

Code to find strings in source code over many urls

I want to enter a very long list of urls and search for specific strings within the source code, outputting a list of urls that contain the string. Sounds simple enough right? I have come up with the bellow code, the input being a html form. You can…
user586011
  • 1,908
  • 4
  • 18
  • 29