1

Thanks for reading. So ok this is what I been working on. I'm making object's, inside my function that contains data for each city in the USA.

The information displays in a custom template that has most of the information for each page.

The objects just change parts of the text like words and sentences. That's why each object needs to be unique.

My question to the StackOverflow community is, is there a way to achieve this faster?

I'm new to PHP but trying really hard. Or how can I make the memory on word press unlimited so I can fit this huge database? That's a lot of cities!

Thanks for reading.

example:

<?php
/**
* Enqueues child theme stylesheet, loading first the parent theme stylesheet.
*/
function themify_custom_enqueue_child_theme_styles() {
    wp_enqueue_style( 'parent-theme-css', get_template_directory_uri() . '/style.css' );
}
add_action( 'wp_enqueue_scripts', 'themify_custom_enqueue_child_theme_styles', 11 );


/****THIS FUNCTION CONTROLS THE CITY DATA BASE!*****/
function get_city_info() {
     $_SERVER['REQUEST_URI'];
    $city_info = [

        '/pageone/denver/' => [
            'city' => 'Denver',
            'state' => 'Colorado',
            'description' => 'Denver description',
            'links' => [
                'lakes' => 'fishing',
                'mountains' => 'snow',
                'hike-trails' => 'road',
                'camping' => 'park'
            ]
        ],

        '/pageone/california/irvine/' => [
            'city' => 'Irvine',
            'state' => 'California',
            'description' => 'Irvine description',
            'links' => [
                'lakes' => 'fishing',
                'mountains' => 'snow',
                'hike-trails' => 'road',
                'camping' => 'park'
            ]
        ]
    ];

    $default = [
        'city' => '',
        'state' => '',
        'description' => '',
        'links' => [
        ]
    ];
    return isset($city_info[$_SERVER['REQUEST_URI']]) ? $city_info[$_SERVER['REQUEST_URI']] : $default;

}
/***********************************************************/
Atanas
  • 366
  • 2
  • 17
ann non
  • 21
  • 3
  • You can programmatically increased it like below:- `ini_set('memory_limit','16M'); // increase to 16 mb ini_set("memory_limit", "-1"); // unlimited` Important Note:- Memory limitation comes through OS, not from PHP itself. So even the above code will not ensure that you will not get Out of memory error. So try to use OS with bigger RAM size Reference:- http://stackoverflow.com/a/17187836/4248328 – Alive to die - Anant May 05 '17 at 07:04

0 Answers0