Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
From web scalping i get array like
1JANATAMF 7.20 -0.10 -1.37%
1STPRIMFMF 11.80 -0.10 -0.84%
AAMRATECH 32.80 0.40 1.23%
and many row.
I want to separate value like 1JANATAMF,7.20,-0.10,-1.37% or insert value to mysql data base by 1JANATAMF as a name and price as 7.20
How can i do this?
Regex: "#\s+#" Here we are matching string on one or more spaces.
Try this code snippet here
<?php
ini_set('display_errors', 1);
$data=array(
"1JANATAMF 7.20 -0.10 -1.37%",
"1STPRIMFMF 11.80 -0.10 -0.84%",
"AAMRATECH 32.80 0.40 1.23%"
);
foreach($data as $value)
{
print_r(preg_split("#\s+#", $value));
}
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 days ago.
Improve this question
I'm creating a database table for images, but when I am going to insert data(img) above 20 then I can't able to insert data. My table rows only able to insert data only 20. I want insert data number of 30 or 50. So how can I fix this problem.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I have a array as below
$x= array("Name","Age","Place","John",34,"London","Ram",12,"New Delhi");
here I've to get as below
Name Age Place
John 34 London
Ram 12 New Delhi
is there any option to do this?
If you know the number of column you can use array-chunk :
$x= array("Name","Age","Place","John",34,"London","Ram",12,"New Delhi");
foreach(array_chunk($x, 3) as $row) // 3 is the number of column
echo implode("\t", $row) . PHP_EOL;
This will generate the output as:
Name Age Place
John 34 London
Ram 12 New Delhi
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I had this code
$loop ="5";
$value = "1";
how to insert value to db like this 1:1:1:1:1 (where loop have 5)
thanks
string $val_for_Db = "";
for ($i=0;$i<$loop;$i++) {
$val_for_Db = $val_for_Db."".$value.":";
}
$val_for_Db = substr($val_for_Db ,-1);
Now insert $val_for_Db to database.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
<?php
$x=6;
$y=9;
$time = array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
for ($i=$x;$i<=count($y);$i++)
{
If($x!=$y)
{
$time[$i]=1;
}
}
?>
Depending on the value of x and y,the values in array should change.
In this example... array[5] until array[8] should be value 1.
The value of x and y will not same.
Not a very good question, but I'm a little bored. So for fun:
array_splice($time, $x-1, $y-$x-1, array_fill(0, $y-$x+1, 1));
Not exactly sure of the logic using 6 and 9 and array[5] until array[8] is, but adjust the numbers to fit the range.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Hello I have this array:
$_SESSION['id'] = array();
I would like to select all array ID'S and then select them from the database.
How to do it? I have no idea..
$sql='select name from table where id in ('.implode(",",$_SESSION['id']).')';