Answer the question
In order to leave comments, you need to log in
How to add text from a variable to an array?
Good afternoon!
Faced a problem, it is necessary to write the numbers from the variable to the array
array (
[0] => 1.8
[1] => 1.4
[2] => 1.2
[3] => 0.8
[4] => 4
Information in the HTML code is displayed line by line, I tried to split it using "explode(" ", $name)", taking into account spaces, but the line is wrapped without spaces. (1,81,41,20,84)
Alternatively, you can cut the line two characters each, but in dynamics there may be longer lines.
Help, how can these transfers be taken into account and write data to an array separated by lines.
Thank you!
The output code looks like this (3 variables with numbers arr1_1, arr1_2, arr1_3):
<html>
<head>
<title> Some
</title>
<meta charset="UTF-8">
<link rel="stylesheet" href="Style.css">
</head>
<body>
<br/><h1>Парсинг с сайта</h1><br/></br>arr1_1string(17) "1,8
1,4
1,2
0,8
4"
</br>arr1_2)
1,3
0,7
0,9
0,3
2</br>arr1_3)
0,5
0,7
0,3
0,5
3
4
10
10
Answer the question
In order to leave comments, you need to log in
I can't understand why the information that I parsed was written to a variable in this form.
That
is, "arr1_1string(17) "1.8
1.4
1.2
0.8
4"
This is the result of the command "var_dump ($arr1_1);" , the result is displayed line by line, although, apparently, the info comes in one line "1,81,41,20,84".
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question