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
0
votes
2 answers

explode function isn't retaining order but putting words into alphabetical order within the array

I have a variable with some various phrases/words in there, these are all separated by a comma. They are currently in the correct order within this variable. However when I use The result when I loop through…
0
votes
1 answer

convert | separated values into new table using PHP

Edit: I forgot to add the explode part that I'm having the issues with. I need the query result exploded. I have been messing with this for a while and have a workable procedure in mysql, however I want to accomplish this as part of a larger script.…
caro
  • 863
  • 3
  • 15
  • 36
0
votes
2 answers

PHP explode, save the "leftovers"

In this scenario everything works as expected: $someString = '1|2|3|4'; list($val1, $val2, $val3, $val4) = explode("|", $someString); In the followin scenario there are more values in the $someString than what there are $vals to put them…
Jani
  • 47
  • 7
0
votes
3 answers

explode and then foreach data not the same (php error?)

I have 2 string : $data1 = "8,11,"; $data2 = "2,3,"; and I do this : $stuff = explode(",", $data1, -1); $amount = explode(",", $data2, -1); So the array like this : $stuff have an Array ( [0] => 8 [1] => 11 ) $amount have an Array ( [0] => 2 [1]…
Azhar
  • 329
  • 1
  • 4
  • 17
0
votes
2 answers

on click link display string which first character is between 0-9

Am trying to display a string from my database where the first character is between 0 to 9 i tried it but still did not work below is my code help me with it thanks. if(isset($_REQUEST['num'])){ $num = explode('-',$_REQUEST['num']); $query1 =…
simon oni
  • 35
  • 6
0
votes
1 answer

PHP - Explode/ substr/ Filename

See previous Question which was partly answered but there has been a change in requirements for the script: PHP - Exploding / Moving / Filename i'm new to php and am stuck. I have loads of files that look like this: 2014-04-01 NS122345 - The date,…
Simpson
  • 42
  • 7
0
votes
2 answers

Need help using explode, preg_match

I have over one thousand reviews in a string. I have been asked to see if i can get the average rate from each author. an example of the string is below. I have highlighted the content which I need to extract into an array. Shepherd's Bush Empire…
gareth
  • 179
  • 2
  • 18
0
votes
3 answers

need to explode tags to array in php language

I have my tags in line: word1 word2 word3 "word4 word1" word4 "word7 word4" "word67 word56 word1" word7 need to get everything in array like: word1 word2 word3 word4 word1 word4 word7 word4 word67 word56 word1 word7 need to do it with explode("…
vagiz
  • 313
  • 2
  • 15
0
votes
2 answers

How to read an Array and save

I'm trying to read an array to save some values but it doesnt work! Here's my code: $array=$_POST['idprod'];//I get my array and save it on a var print_r($array); //It has ALL the data (I use a print_r($array); And YES!! It has the information i…
Jean
  • 593
  • 2
  • 6
  • 19
0
votes
1 answer

How to parse information not using explode?

I have some Information which i have parsed from the Wikipedia Infobox using the Wikipedia API. One of my Information which i want to parse is the birthdate: $birthdate = "birth_date = {{Birth date|1958|8|29}}" i want have the birtdate information…
R2D2
  • 743
  • 1
  • 7
  • 14
0
votes
0 answers

Split MySQL column value to words and insert

I have a simple task to do. I have a long text in DB column and I need to break this long text for words and put each word to another table, lets say to fts_words: (id INT, wrd VARCHAR[255]). I can't find anything like split() or explode() in MySQL…
Epsiloncool
  • 1,435
  • 16
  • 39
0
votes
1 answer

PHP - Exploding / Moving / Filename

Wonder if you can help, i'm new to php and am stuck. I have loads of files that look like this: 2014-04-01 NS122345 - The date, the initials of the person and there employee code. I want to be able to move the files that have NS or JB Or GA into…
Simpson
  • 42
  • 7
0
votes
0 answers

fopen Data save in Database

I want to save datas from an fopen link into my database .. i get some help to use explode .. for that i got some code which should work .. but it doesn´t. i have an error somewhere but i cannot find it (i cut out the database connection part to…
Dave
  • 27
  • 10
0
votes
2 answers

MySQL CONCAT_WS three columns, echo result in foreach loop after explode()

I have this as result from MySQL (stored as $result) +-------------------------------------------------------------------------+ | CONCAT_WS('::', p.isMobile, p.contact_phone_id, p.contact_phone_number)…
David
  • 1,171
  • 8
  • 26
  • 48
0
votes
3 answers

PHP - counting an imploded array

I am trying to use sizeof or count to return the number of things inside the array, however whenever I use the $rank_ids2 to count rather than entering 1, 2, 3, 4, 67, 7 in manually, it just returns 1, but when I type them in the array directly, it…
Jayden
  • 437
  • 2
  • 7
  • 11
1 2 3
99
100