array_push

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



How can I clean this up?
My approach would be to split the hole text into smaller chunks (with e.g. explode()) and extract the interesting parts with a regular expression. Maybe this will give you some ideas:
$chunks = explode("-30-", $mystring);
foreach($chunks as $chunk) {
         preg_match_all("/News Releases\n(.+)/s", $chunk, $matches);
         var_dump($matches[1]);
}
The regex matches all text between "News Releases" and the end of the chunk.
2) How could I suck it into one nice easy to handle array?

|$mynewarray=|array {
  [0]=> "Residential Fire Determined to be Accidental in Nature ..."
  [1]=> "Arrest Made in Residential Fire ..."
}
I was hoping preg_match_all would return strings. I w/as hoping |$matches[1] was a string.|/

source: http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test4.phps
result: http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test4.php

This is ugly. How can I clean this up like this?

$mynewarray= array {
  [0]=> "Residential Fire Determined to be Accidental in Nature ..."
  [1]=> "Arrest Made in Residential Fire ..."
}

I wanted to push $matches[] (which I hoped was a string, not an array). I probably don't understand what preg_match_all did.

Now I have arrays nested inside the array(). How can I clean it up?

http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test4.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux