Results 1 to 2 of 2

Thread: while loop inside array

  1. #1
    Join Date
    Dec 2006

    while loop inside array

    I have a class to change urls from Opencart. There's array of urls and their new values. My problem is I'd like to get those urls and values from mySQL database.

    Original array is something as this:

    PHP Code:
    var $pages = array('contact' => 'common/home''search' => 'product/search', ...); 
    I tried to do it this way:

    PHP Code:
    while ($row mysql_fetch_array($result)) {
    $pages[] = array($row['route_seo_url'] => $row['route_old_url']);

    and inside class:

    PHP Code:
    var $pages = array(); 
    but it doesn't work.

    This is whole original code:

    PHP Code:
    class ControllerCommonRoute extends Controller {

    $pages = array('contact' => 'common/home''search' => 'product/search', ...);

        public function 
    check() {

    $uri substr(str_replace(strrchr($this->request->server['REQUEST_URI'], '?'), ''$this->request->server['REQUEST_URI']),);
    $uri = (substr($uri, -1)=='/')? $uri substr($uri0strrpos($uri'/')) : $uri;

    $this->request->get['route'])) AND (trim($uri) <> '')){
    $this->request->get['route'] = $this->pages[$uri];


    Any suggestions will be appreciated.

  2. #2
    Join Date
    Aug 2011
    setting an array value
    PHP Code:
    creating an array variable
    PHP Code:
    PHP Code:
    $pages =array($row['route_seo_url'],$row['route_old_url']);
    $pages[0// route_seo_url
    $pages[1// route_old_url 
    PHP Code:
    $pages[] =array($row['route_seo_url'],$row['route_old_url']);
    $pages[0][0// route_seo_url
    $pages[0][1// route_old_url 
    Last edited by Dorky; 09-27-2011 at 12:36 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center