Sometimes, arrays are not used to store information; instead, a string is used. The single values are all within the string, but are separated by a special character.
The following example convert string into array -
<?php
$csvdata = 'Burch Jr, Philip H., The American establishment, Research in political economy 6(1983), 83-156';
$a = explode(',', $csvdata);
$info = print_r($a, true);
echo "<pre>$info</pre>";
?>
The PHP function explode() creates an array out of these values, you just have to provide the character(s) at which the string needs to be split.
Output of the above code -
Array
(
[0] => Burch Jr
[1] => Philip H.
[2] => The American establishment
[3] => Research in political economy 6 (1983)
[4] => 83-156
)
Solution
Sometimes, arrays are not used to store information; instead, a string is used. The single values are all within the string, but are separated by a special character.
The following example convert string into array -
The PHP function explode() creates an array out of these values, you just have to provide the character(s) at which the string needs to be split.
Output of the above code -
need an explanation for this answer? contact us directly to get an explanation for this answerArray ( [0] => Burch Jr [1] => Philip H. [2] => The American establishment [3] => Research in political economy 6 (1983) [4] => 83-156 )