PHP doesn't like array defined

I'm converting BLOBs of data from a MySQL database. Each of these BLOBs is the body portion of HTML files I'm converting to XHTML. Mainly, I'm checking <p> tags for case and closing tag. There are over 500 of these BLOBS. Hence, I want the automate the checking and editing of tags as much as possible.

Here is the code I have written so far, abbreviated to the section I am having problems with and what I want to achieve. Explanation appears below.

Retrieve the BLOB from the database 1 record at a time and assign it to the variable $body.

Strip the slashes.

Count the number of occurrences of <P> in the code always starting from 0. As the While{} runs, it returns the offset for each occurrence of the next <P> as the present occurrence is converted to <p>. Each of these off-set numbers is appended to a string building an array that will be later used.

The lines of code with echo at the start are merely for tracking progress in this debugging phase.

If you are, I don't think this will work, because you have it inside double quotes, I think "array()" is being passed as a string and not being defined as an array. Unless of course you a want to pass it as a string? I may be offbase with this, But I am pretty sure that is it being passed as a string therefore $a is not storing an array.

If $a was an array, It wouldn't print anything if you give echo $a. It will give aray().
So, obviously,
that wouldn't work since foreach takes an array as an argument. I don't think $a stores an array.

Are you trying to set variable $a to an array here on line 24:

$a="array(".$strt.", ";
} else {
$a=$a.$strt.", ";

If you are, I don't think this will work, because you have it inside double quotes, I think "array()" is being passed as a string and not being defined as an array. Unless of course you a want to pass it as a string? I may be offbase with this, But I am pretty sure that is it being passed as a string therefore $a is not storing an array.

That which I am trying to achieve is take the value of variable $strt and append it to a string with each run of the loop.

//if x < 1, then this is the first run of the loop, initiate the string
if ($x<1) {
$a="array(".$strt.", ";
} else {
//if greater than the first run of the loop, append $strt value to existing string if $a
$a=$a.$strt.", ";
}

Once the loops end the variable $a looks like this:
array(0, 204, 460, 586, 709, 826,

The code

//trim the variable a by 2 (eliminate the last , ) and close off the string
$a = substr($a,0,strlen($a)-2).")";

To me, that looks like $a=array(0, 204, 460, 586, 709, 826). How is that different from simply typing $b=array(0, 204, 460, 586, 709, 826) as I did in my example? The data under $a is not seen as an array but the same string of text under $b is seen as an array.

Since PHP is not interpreting $a as an array, how else can I collect each variable of $strt in a string or some other manner to later declare them as values in an array? If keys are not being stated, does an array always have to be declared by entering $variable = array(value1, value2, value3...)

Because in the first case, $a is considered as a string, since "array(" is in double quotes. In the second case, $a is declared as an array. Instead of assigning the value to $a, you can do it this way.

$values="";
for($i=0;$i<10;$i++){
$values.=$i.";";
}

So, by the end of the loop, $values will have a collection of values separated by ;. You can then assign this value to an array by exploding it.
ie., $a=explode(";",$values); So, $a will have an array of values.

I have a 2d matrix with dimension (3, n) called A, I want to calculate the normalization and cross product of two arrays (b,z) (see the code please) for each column (for the first column, then the second one and so on).
the function that I created to find the ...

I'm working in Excel to extract content of a table from a web page and populate Excel sheet cells with it. I'm trying to extract data from a table that gets loaded to a web page after show results method gets called. I have an error that says "Run-time error ...