0

My code is as follows:

foreach ($row_result as $results)
{
  $f = fopen("jigsaw.csv", "a+");
  $new_array = array();
  $content = $results->findElement(WebDriverBy::className('seo-company'))->geTtext();
  $test = array();
  if ($i == 1)
  {
    $Orgnisation_name = $content;
    $concate = array_push($test,$Orgnisation_name);
    echo "\n";
  }  
  if ($i == 2)
  {
    echo $Website = $content;
    echo "\n";
  }  
  if ($i == 3)
  {
    echo $HeadQuarters = $content;
    echo "\n";
  }  
  if ($i == 4)
  {
    echo $Phone = $content;
    echo "\n";
  }  
  if ($i == 5)
  {
    echo $Industries = $content;
    echo "\n";
  }  
  if ($i == 6)
  {
    echo $Employees = $content;
    echo "\n";
  }  
  if ($i == 7)
  {
    echo $Revenue = $content;
    echo "\n";
  }  
  if ($i == 8)
  {
    echo $Ownership = $content;
    echo "\n";
  }  
  $i++;
} 

Here I want to push one by one element into concate array and finally save it into mysql php database.

When I try to push it into concate array its printing me 1 which is wrong.

What should I do?

2 Answers 2

2

array_push return value is:

Returns the new number of elements in the array.

So 1 is the number of elements in array.

Seems that you will always have 1, because you call $i++ and according to your code, block with array_push will be executed once.

Sign up to request clarification or add additional context in comments.

Comments

1

Do you need to use array_push? $concate = array_push($test,$Orgnisation_name); $test is blank at this point. If you just want to add an item to the $concate array, $concate[] = $Orgnisation_name; is enough.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.