explode

Php explode then get the name row from a MySql Table

I know this has been talked about here before. However, my situation is a bit different and I'm so close. I would like to explode an array of category id's from a news data table then get the category name from the category table. Right now I am able to get the id's out and explode them just fine inside the while loop for the news da...

undefined offset when using php explode()

I've written what I thought was a very simple use of the php explode() function to split a name into forename and surname: // split name into first and last $split = explode(' ', $fullname, 2); $first = $split[0]; $last = $split[1]; However, this is throwing up a php error with the message "Undefined offset: 1". The function still see...

PHP Email Array Regular Expression

Given a list of emails, formated: "FirstName Last" <[email protected]>, "NewFirst NewLast" <[email protected]> How can I build this into a string array of Only email addresses (I don't need the names). ...

Multiple Select with Explode: only returns the word "Array"

Using Wordpress I have created a multiple select box so that users can select categories to exclude. When the page initially loads I see my default values pre-selected. However when I select new values and save... I only see the word "Array" echoed and nothing selected? <select class="amultiple" id="<?php echo $value['id']; ?>" name="<...

Weird behavior of jQuery UI Explode in Internet Explorer

I'm trying to show an background-image after a user clicks on a box. (I know I'm a bit lazy on the CSS) <script type="text/javascript"> $(document).ready(function() { var options = {}; $(".toggler1").click(function() { $("#effect1").effect("explode",options,1000); $(".toggler1").html("<div id='effect1b' style='floa...

PHP explode function

I want to let the user type in tags: windows linux "mac os x" and then split them up by white space but also recognizing "mac os x" as a whole word. Is this possible to combine the explode function with other functions for this? There has to be a way. ...

PHP explode is removing the first array value

Ok, first off, I applogize if this question has been asked before, I've spent the last 12 hours sifting through hundreds of forum threads and haven't found one that answers this question exactly yet so here goes. I have a page that I built that has a userlist that is autopopulated as users log in, and each users has a checkbox that allo...

How to un-nest nested lists in php

I have a nested unordered list like this (simplified version / the depth is variable) : <ul> <li> <a href="#">Root</a> <ul> <li> <a href="#">Page A</a> <ul> <li> <a href="#" title="Page A1">Page 1 2</a> </li> ...

How to 'explode' this page output

Hi, I'm trying to parse the output of this page -> http://master.anti3d.com/raw_server_list2.php The documentation of that master server says that every entry is separated in this way Note: LF = LineFeed = 10 Format: serverName[LF]ipAddress:port;users/maxusers;gameCount;version;location[LF] Example: Server Name1 ...

Can this snippet be further optimized / organized?

From my related question here at SO I've come up with the following PHP snippet: $url = parse_url($url); if (is_array($url)) { $depth = 2; $length = 50; if (array_key_exists('host', $url)) { $result = preg_replace('~^www[.]~i', '', $url['host']); if (array_key_exists('path', $url)) { ...

PHP Strip string of first url and report results

Russel Peter video: <a rel="nofollow" href="http://www.youtube.com/watch?v=2bP9tRhJRTw"&gt;www.youtube.com/watch?v=2bP9tRhJRTw&lt;/a&gt; russel peters video blah blah. Turtles: <a href="http://turtles.com"&gt;turtles.com&lt;/a&gt; I have a string that contains text and and tags with enclosed urls like the above example. I want to str...

Exploding and replacing one array field

So, I have an array that, for unrelated reasons, has one imploded field in itself. Now, I'm interested in exploding the string in that field, and replacing that field with the results of the blast. I kinda-sorta have a working solution here, but it looks clunky, and I'm interested in something more efficient. Or at least aesthetically pl...

PHP: Split string into array, like explode with no delimiter...

I have a string such as: "0123456789" and need to split EACH character into an array. I for the hell of it tried: explode('', '123545789'); But it gave me the obvious: Warning: No delimiter defined in explode) .. How would I come across this? I can't see any method off hand, especially just a function ...

PHP explode the string, but treat words in quotes as a single word.

How can I explode the following string: Lorem ipsum "dolor sit amet" consectetur "adipiscing elit" dolor into array("Lorem", "ipsum", "dolor sit amet", "consectetur", "adipiscing elit", "dolor") So that the text in quotation is treated as a single word. Here's what I have for now: $mytext = "Lorem ipsum %22dolor sit amet%22 consect...

Why can't I access the exploded array element immediately?

Why can't I immediately access elements in the array returned by explode()? For example, this doesn't work: $username = explode('.',$thread_user)[1]; //Parse error: syntax error, unexpected '[ But this code does: $username = explode('.',$thread_user); $username = $username[1]; I don't usually program in PHP, so this is rather co...

Get content from string in different situations

Hi, I'm thinking of storing data from a form as a string, each answer separated by a pipe. The problem I have is that some answers may come in the form of multiple items. We store the radio button selection along with their corresponding answers e.g. Question 1 - 1 Answer [A1] Question 2 - Radio button selected [A2] + 3 form fields Que...

read textfile with delimiter in php

I have three eintries in a textfile.txt: 20100220 Hello Here is Text \n blah \t even | and & and so on... I want to read each entrie (line) as a new string in php. I thought of using fopen and fgets. But: Since I'm using special characters like \n in the last line, fgets() would not work because it will terminate the string at \n, rig...

list and explode

Hey everyone, I am trying to use url rewriting on my website and I want to use the list() and explode() functions to get the right content. Currently my code looks like this: list($dir, $act) = explode('/',$url); In this case $url is equal to everything after the first slash in the absolute url i.e. http://example.com/random/stuff =>...

Replace use of explode() with str_split()

$transData = fgets($fp); while (!feof ($fp)) { $transArry = explode(" ", $transData); $first = $transArry[0]; $last = $transArry[1]; $Sub = $transArry[2]; $Grade= $transArry[3]; echo "<table width='400' ><colgroup span='1' width='35%' /><colgroup span='2' width='20%' /> <tr><td> ".$first." ".$last." </td><td> ...

PHP, CSV columns into separate arrays

Basically, i want to make a system where a user can upload a CSV file and pick what columns they want to upload/process I can do this fine by using fopen and foreach, but since the number of the column may vary from CSV to CSV.... i can store the picked columns in an array, eg picked[]= "1,2,4"; //from 1,2,3,4 columns comma separated...