in Education by
PHP's explode function returns an array of strings split on some provided substring. It will return empty strings when there are leading, trailing, or consecutive delimiters, like this: var_dump(explode('/', '1/2//3/')); array(5) { [0]=> string(1) "1" [1]=> string(1) "2" [2]=> string(0) "" [3]=> string(1) "3" [4]=> string(0) "" } Is there some different function or option or anything that would return everything except the empty strings? var_dump(different_explode('/', '1/2//3/')); array(3) { [0]=> string(1) "1" [1]=> string(1) "2" [2]=> string(1) "3" } JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Try preg_split. $exploded = preg_split('@/@', '1/2//3/', NULL, PREG_SPLIT_NO_EMPTY);

Related questions

0 votes
    PHP's explode function returns an array of strings split on some provided substring. It will return empty ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 27, 2022 in Education by JackTerrance
0 votes
    PHP's explode function returns an array of strings split on some provided substring. It will return empty ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 27, 2022 in Education by JackTerrance
0 votes
    please see my code below, example_list = [ ['a','b','c'], ['f','g','h'], ['i','j','k'], ] my_string = ''' ' ... g','h'), ('i','j','k'); Select the correct answer from above options...
asked Jan 19, 2022 in Education by JackTerrance
0 votes
    How do you check for an empty (zero Element) array?...
asked Apr 24, 2021 in Technology by JackTerrance
+1 vote
    Which is the correct way to create an Empty array in JavaScript? I) var myProg = []; II) var myArray = ["C","Java","C++","Python ... = new Array(); I, III II, III I, II I, II & III...
asked Oct 9, 2020 in Technology by JackTerrance
0 votes
    I am a newbie to Scala and I want to learn how can I add null and empty check on an optional ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 6, 2022 in Education by JackTerrance
0 votes
    I am a newbie to Scala and I want to learn how can I add null and empty check on an optional ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 26, 2022 in Education by JackTerrance
0 votes
    In the code below, in "parse" function I am trying to get substring from the string "line". I am ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 16, 2022 in Education by JackTerrance
0 votes
    I am a newbie to Scala and I want to learn how can I add null and empty check on an optional ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 12, 2022 in Education by JackTerrance
0 votes
    In the code below, in "parse" function I am trying to get substring from the string "line". I am ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 5, 2022 in Education by JackTerrance
0 votes
    I have a table which contains 'NULL' values which are of type 'Datetime'. Now i have to convert ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 22, 2022 in Education by JackTerrance
0 votes
    Does Python have something like an empty string variable where you can do: if myString == string.empty: Regardless, ... not as good. Select the correct answer from above options...
asked Jan 22, 2022 in Education by JackTerrance
0 votes
    I am trying to print a particular text using awk if string is empty. It works fine in the below ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jan 13, 2022 in Education by JackTerrance
...