I’m getting data from an array. For some reason the array has key values like [3.3] which I’m having trouble retrieving data from. I have this array [3.3] => First Name [3.6] => Last Name[2] => email@example.com. When I try to call $array[3.3] it returns null, but when I call $array[2] I …
Tag: php
Quickest Way to Read First Line from File
What’s the quickest, easiest way to read the first line only from a file? I know you can use file, but in my case there’s no point in wasting the time loading the whole file. Preferably a one-liner.
Javascript Equivalent to PHP Explode()
I have this string: 0000000020C90037:TEMP:data I need this string: TEMP:data. With PHP I would do this: How do I effectively explode a string in JavaScript the way it works in PHP? Answer This is a direct conversion from your PHP code:
PHP Framework vs Content Management System
How would you explain the difference between a PHP Framework and a CMS (like WordPress) to someone who is very technically savvy, mostly on hardware/networking, but does little or no programming? As …
MySQL: dates before 1970
I’m working on a church site which has many events before 1970, these events starts from 1001 to today, how can I store the dates in MySQL? This works fine only for dates after 1970, how can I store dates before this year? What kind of datatype should I have in MySQL? Now I’ve set my column to dat…
Delete element from multidimensional-array based on value
I’m trying to delete elements from a multidimensional-array based on a value. In this case if a sub-array’s key ‘year’ has the value 2011 I want that sub-array out. Just for the record: i’m running PHP 5.2. My array looks like this: Answer Try this: Then you would call it like th…
How to redirect subdomain to main domain maintaining the same URL?
My main domain(www.mysite.com) is pointing to a folder in my server (/home/user_name/htdocs/mysite.com). I have recently created a subdomain(m.mysite.com) through my hosting account. But it is pointing it to a new folder (/home/user_name/htdocs/m.mysite.com) in my server. I am not able to edit the path to whi…
PHP: Change only a portion of a URL string?
I’m working on a small hoppy project where I want to replace a specific page on a URL. Let me explain: I’ve got the URL http://www.example.com/article/paragraph/low/ I want to keep the URL but …
Parse inline CSS values with Regex?
I have such an inline CSS like this color:#777;font-size:16px;font-weight:bold;left:214px;position:relative;top:70px The CSS may end with a semicolon “;” or not. It also can contain extra space …
More efficient query in mysql
I want to know how do they do a query with only one textbox in the page, but the current text in the text box can be used as a parameter for the query. I’m currently using the query below but I don’t …